@@ -43,7 +43,11 @@ class ChecksumCalculatorTest {
4343 @ Test
4444 void itCalculatesAChecksumForStep () {
4545 Step step = step (
46- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
46+ randomPath (),
47+ randomString (),
48+ argGroup (null , randomByteArray ()),
49+ argGroup (randomString (), null ),
50+ List .of (randomPath (), randomPath ()));
4751
4852 String checksum = checksumCalculator .calculateChecksum (step );
4953
@@ -52,10 +56,18 @@ void itCalculatesAChecksumForStep() {
5256
5357 @ Test
5458 void itCalculatesDifferentChecksumsForSteps () {
55- Step step1 =
56- step (randomPath (), randomString (), argGroup (randomString (), null ), List .of (randomPath (), randomPath ()));
59+ Step step1 = step (
60+ randomPath (),
61+ randomString (),
62+ argGroup (randomString (), null ),
63+ argGroup (null , randomByteArray ()),
64+ List .of (randomPath (), randomPath ()));
5765 Step step2 = step (
58- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
66+ randomPath (),
67+ randomString (),
68+ argGroup (null , randomByteArray ()),
69+ argGroup (randomString (), null ),
70+ List .of (randomPath (), randomPath ()));
5971
6072 String checksum1 = checksumCalculator .calculateChecksum (step1 );
6173 String checksum2 = checksumCalculator .calculateChecksum (step2 );
@@ -66,7 +78,11 @@ void itCalculatesDifferentChecksumsForSteps() {
6678 @ Test
6779 void itRecalculatesSameChecksumsForStep () {
6880 Step step = step (
69- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
81+ randomPath (),
82+ randomString (),
83+ argGroup (null , randomByteArray ()),
84+ argGroup (randomString (), null ),
85+ List .of (randomPath (), randomPath ()));
7086
7187 String checksum1 = checksumCalculator .calculateChecksum (step );
7288 String checksum2 = checksumCalculator .calculateChecksum (step );
@@ -77,7 +93,11 @@ void itRecalculatesSameChecksumsForStep() {
7793 @ Test
7894 void itCalculatesAChecksumForCommandLineStream () {
7995 Step step = step (
80- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
96+ randomPath (),
97+ randomString (),
98+ argGroup (null , randomByteArray ()),
99+ argGroup (randomString (), null ),
100+ List .of (randomPath (), randomPath ()));
81101 Action action = action (randomPath ());
82102 SpotlessCommandLineStream commandLineStream = commandLine (action , step );
83103
@@ -89,7 +109,11 @@ void itCalculatesAChecksumForCommandLineStream() {
89109 @ Test
90110 void itCalculatesDifferentChecksumForDifferentCommandLineStreamDueToAction () {
91111 Step step = step (
92- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
112+ randomPath (),
113+ randomString (),
114+ argGroup (null , randomByteArray ()),
115+ argGroup (randomString (), null ),
116+ List .of (randomPath (), randomPath ()));
93117 Action action1 = action (randomPath ());
94118 Action action2 = action (randomPath ());
95119 SpotlessCommandLineStream commandLineStream1 = commandLine (action1 , step );
@@ -104,9 +128,17 @@ void itCalculatesDifferentChecksumForDifferentCommandLineStreamDueToAction() {
104128 @ Test
105129 void itCalculatesDifferentChecksumForDifferentCommandLineStreamDueToSteps () {
106130 Step step1 = step (
107- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
131+ randomPath (),
132+ randomString (),
133+ argGroup (null , randomByteArray ()),
134+ argGroup (randomString (), randomByteArray ()),
135+ List .of (randomPath (), randomPath ()));
108136 Step step2 = step (
109- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
137+ randomPath (),
138+ randomString (),
139+ argGroup (null , randomByteArray ()),
140+ argGroup (randomString (), randomByteArray ()),
141+ List .of (randomPath (), randomPath ()));
110142 Action action = action (randomPath ());
111143 SpotlessCommandLineStream commandLineStream1 = commandLine (action , step1 );
112144 SpotlessCommandLineStream commandLineStream2 = commandLine (action , step2 );
@@ -120,9 +152,17 @@ void itCalculatesDifferentChecksumForDifferentCommandLineStreamDueToSteps() {
120152 @ Test
121153 void itCalculatesDifferentChecksumForDifferentCommandLineStreamDueToStepOrder () {
122154 Step step1 = step (
123- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
155+ randomPath (),
156+ randomString (),
157+ argGroup (null , randomByteArray ()),
158+ argGroup (null , randomByteArray ()),
159+ List .of (randomPath (), randomPath ()));
124160 Step step2 = step (
125- randomPath (), randomString (), argGroup (null , randomByteArray ()), List .of (randomPath (), randomPath ()));
161+ randomPath (),
162+ randomString (),
163+ argGroup (null , randomByteArray ()),
164+ argGroup (null , randomByteArray ()),
165+ List .of (randomPath (), randomPath ()));
126166 Action action = action (randomPath ());
127167 SpotlessCommandLineStream commandLineStream1 = commandLine (action , step1 , step2 );
128168 SpotlessCommandLineStream commandLineStream2 = commandLine (action , step2 , step1 );
@@ -133,11 +173,41 @@ void itCalculatesDifferentChecksumForDifferentCommandLineStreamDueToStepOrder()
133173 assertThat (checksum1 ).isNotEqualTo (checksum2 );
134174 }
135175
136- private static Step step (Path test1 , String test2 , StepArgGroup argGroup , List <Path > parameters ) {
176+ @ Test
177+ void itCalculatesDifferentChecksumDueToDifferentSetterOption () {
178+ Path test1 = randomPath ();
179+ String test2 = randomString ();
180+ Step step1 = step (test1 , test2 , randomString (), null , null , List .of ());
181+ Step step2 = step (test1 , test2 , randomString (), null , null , List .of ());
182+
183+ Action action = action (randomPath ());
184+ SpotlessCommandLineStream commandLineStream1 = commandLine (action , step1 );
185+ SpotlessCommandLineStream commandLineStream2 = commandLine (action , step2 );
186+
187+ String checksum1 = checksumCalculator .calculateChecksum (commandLineStream1 );
188+ String checksum2 = checksumCalculator .calculateChecksum (commandLineStream2 );
189+
190+ assertThat (checksum1 ).isNotEqualTo (checksum2 );
191+ }
192+
193+ private static Step step (
194+ Path test1 , String test2 , StepArgGroup argGroup , StepArgGroup argGroup2 , List <Path > parameters ) {
195+ return step (test1 , test2 , test1 + test2 , argGroup , argGroup2 , parameters );
196+ }
197+
198+ private static Step step (
199+ Path test1 ,
200+ String test2 ,
201+ String test3 ,
202+ StepArgGroup argGroup ,
203+ StepArgGroup argGroup2 ,
204+ List <Path > parameters ) {
137205 Step step = new Step ();
138206 step .test1 = test1 ;
139207 step .test2 = test2 ;
208+ step .setTest5 (test3 );
140209 step .argGroup = argGroup ;
210+ step .setArgGroup2 (argGroup2 );
141211 step .parameters = parameters ;
142212 return step ;
143213 }
@@ -169,9 +239,26 @@ static class Step extends SpotlessFormatterStep {
169239 @ CommandLine .Option (names = "--test2" )
170240 String test2 ;
171241
242+ private String test5 ;
243+
244+ @ CommandLine .Option (names = "--test5" )
245+ void setTest5 (String test5 ) {
246+ if (test5 == null ) {
247+ throw new NullPointerException ("test5" );
248+ }
249+ this .test5 = test5 ;
250+ }
251+
172252 @ CommandLine .ArgGroup (exclusive = true )
173253 StepArgGroup argGroup ;
174254
255+ private StepArgGroup argGroup2 ;
256+
257+ @ CommandLine .ArgGroup (exclusive = true )
258+ void setArgGroup2 (StepArgGroup argGroup2 ) {
259+ this .argGroup2 = argGroup2 ;
260+ }
261+
175262 @ CommandLine .Parameters
176263 List <Path > parameters ;
177264
0 commit comments