@@ -153,25 +153,25 @@ public Stream<? extends Arguments> provideArguments(final ExtensionContext conte
153153
154154 @ Test
155155 void chainingParsersIgnoreHappyPath () throws ParseException {
156- Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
157- Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
158- Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
159- Option d = Option .builder ().option ("d" ).longOpt ("fourth-letter" ).build ();
156+ final Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
157+ final Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
158+ final Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
159+ final Option d = Option .builder ().option ("d" ).longOpt ("fourth-letter" ).build ();
160160
161- Options baseOptions = new Options ();
161+ final Options baseOptions = new Options ();
162162 baseOptions .addOption (a );
163163 baseOptions .addOption (b );
164- Options specificOptions = new Options ();
164+ final Options specificOptions = new Options ();
165165 specificOptions .addOption (a );
166166 specificOptions .addOption (b );
167167 specificOptions .addOption (c );
168168 specificOptions .addOption (d );
169169
170- String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" };
170+ final String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" };
171171
172- DefaultParser parser = new DefaultParser ();
172+ final DefaultParser parser = new DefaultParser ();
173173
174- CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .IGNORE , args );
174+ final CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .IGNORE , args );
175175 assertEquals (2 , baseCommandLine .getOptions ().length );
176176 assertEquals (2 , baseCommandLine .getArgs ().length );
177177 assertTrue (baseCommandLine .hasOption ("a" ));
@@ -185,7 +185,7 @@ void chainingParsersIgnoreHappyPath() throws ParseException {
185185 assertTrue (baseCommandLine .getArgList ().contains ("arg1" ));
186186 assertTrue (baseCommandLine .getArgList ().contains ("arg2" ));
187187
188- CommandLine specificCommandLine = parser .parse (specificOptions , null , DefaultParser .NonOptionAction .THROW , args );
188+ final CommandLine specificCommandLine = parser .parse (specificOptions , null , DefaultParser .NonOptionAction .THROW , args );
189189 assertEquals (4 , specificCommandLine .getOptions ().length );
190190 assertEquals (2 , specificCommandLine .getArgs ().length );
191191 assertTrue (specificCommandLine .hasOption ("a" ));
@@ -202,52 +202,52 @@ void chainingParsersIgnoreHappyPath() throws ParseException {
202202
203203 @ Test
204204 void chainingParsersIgnoreNonHappyPath () throws ParseException {
205- Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
206- Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
207- Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
205+ final Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
206+ final Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
207+ final Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
208208
209- Options baseOptions = new Options ();
209+ final Options baseOptions = new Options ();
210210 baseOptions .addOption (a );
211211 baseOptions .addOption (b );
212- Options specificOptions = new Options ();
212+ final Options specificOptions = new Options ();
213213 specificOptions .addOption (a );
214214 specificOptions .addOption (b );
215215 specificOptions .addOption (c );
216216
217- String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" }; // -d is rogue option
217+ final String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" }; // -d is rogue option
218218
219- DefaultParser parser = new DefaultParser ();
219+ final DefaultParser parser = new DefaultParser ();
220220
221- CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .IGNORE , args );
221+ final CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .IGNORE , args );
222222 assertEquals (2 , baseCommandLine .getOptions ().length );
223223 assertEquals (2 , baseCommandLine .getArgs ().length );
224224
225- UnrecognizedOptionException e = assertThrows (UnrecognizedOptionException .class ,
225+ final UnrecognizedOptionException e = assertThrows (UnrecognizedOptionException .class ,
226226 () -> parser .parse (specificOptions , null , DefaultParser .NonOptionAction .THROW , args ));
227227 assertTrue (e .getMessage ().contains ("-d" ));
228228 }
229229
230230 @ Test
231231 void chainingParsersSkipHappyPath () throws ParseException {
232- Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
233- Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
234- Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
235- Option d = Option .builder ().option ("d" ).longOpt ("fourth-letter" ).build ();
232+ final Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
233+ final Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
234+ final Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
235+ final Option d = Option .builder ().option ("d" ).longOpt ("fourth-letter" ).build ();
236236
237- Options baseOptions = new Options ();
237+ final Options baseOptions = new Options ();
238238 baseOptions .addOption (a );
239239 baseOptions .addOption (b );
240- Options specificOptions = new Options ();
240+ final Options specificOptions = new Options ();
241241 specificOptions .addOption (a );
242242 specificOptions .addOption (b );
243243 specificOptions .addOption (c );
244244 specificOptions .addOption (d );
245245
246- String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" };
246+ final String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" };
247247
248- DefaultParser parser = new DefaultParser ();
248+ final DefaultParser parser = new DefaultParser ();
249249
250- CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .SKIP , args );
250+ final CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .SKIP , args );
251251 assertEquals (2 , baseCommandLine .getOptions ().length );
252252 assertEquals (4 , baseCommandLine .getArgs ().length );
253253 assertTrue (baseCommandLine .hasOption ("a" ));
@@ -261,7 +261,7 @@ void chainingParsersSkipHappyPath() throws ParseException {
261261 assertTrue (baseCommandLine .getArgList ().contains ("arg1" ));
262262 assertTrue (baseCommandLine .getArgList ().contains ("arg2" ));
263263
264- CommandLine specificCommandLine = parser .parse (specificOptions , null , DefaultParser .NonOptionAction .THROW , args );
264+ final CommandLine specificCommandLine = parser .parse (specificOptions , null , DefaultParser .NonOptionAction .THROW , args );
265265 assertEquals (4 , specificCommandLine .getOptions ().length );
266266 assertEquals (2 , specificCommandLine .getArgs ().length );
267267 assertTrue (specificCommandLine .hasOption ("a" ));
@@ -278,54 +278,54 @@ void chainingParsersSkipHappyPath() throws ParseException {
278278
279279 @ Test
280280 void chainingParsersSkipNonHappyPath () throws ParseException {
281- Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
282- Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
283- Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
281+ final Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
282+ final Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
283+ final Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
284284
285- Options baseOptions = new Options ();
285+ final Options baseOptions = new Options ();
286286 baseOptions .addOption (a );
287287 baseOptions .addOption (b );
288- Options specificOptions = new Options ();
288+ final Options specificOptions = new Options ();
289289 specificOptions .addOption (a );
290290 specificOptions .addOption (b );
291291 specificOptions .addOption (c );
292292
293- String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" }; // -d is rogue option
293+ final String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" }; // -d is rogue option
294294
295- DefaultParser parser = new DefaultParser ();
295+ final DefaultParser parser = new DefaultParser ();
296296
297- CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .SKIP , args );
297+ final CommandLine baseCommandLine = parser .parse (baseOptions , null , DefaultParser .NonOptionAction .SKIP , args );
298298 assertEquals (2 , baseCommandLine .getOptions ().length );
299299 assertEquals (4 , baseCommandLine .getArgs ().length );
300300
301- UnrecognizedOptionException e = assertThrows (UnrecognizedOptionException .class ,
301+ final UnrecognizedOptionException e = assertThrows (UnrecognizedOptionException .class ,
302302 () -> parser .parse (specificOptions , null , DefaultParser .NonOptionAction .THROW , args ));
303303 assertTrue (e .getMessage ().contains ("-d" ));
304304 }
305305
306306 @ Test
307307 void legacyStopAtNonOption () throws ParseException {
308- Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
309- Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
310- Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
308+ final Option a = Option .builder ().option ("a" ).longOpt ("first-letter" ).build ();
309+ final Option b = Option .builder ().option ("b" ).longOpt ("second-letter" ).build ();
310+ final Option c = Option .builder ().option ("c" ).longOpt ("third-letter" ).build ();
311311
312- Options options = new Options ();
312+ final Options options = new Options ();
313313 options .addOption (a );
314314 options .addOption (b );
315315 options .addOption (c );
316316
317- String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" }; // -d is rogue option
317+ final String [] args = {"-a" , "-b" , "-c" , "-d" , "arg1" , "arg2" }; // -d is rogue option
318318
319- DefaultParser parser = new DefaultParser ();
319+ final DefaultParser parser = new DefaultParser ();
320320
321- CommandLine commandLine = parser .parse (options , args , null , true );
321+ final CommandLine commandLine = parser .parse (options , args , null , true );
322322 assertEquals (3 , commandLine .getOptions ().length );
323323 assertEquals (3 , commandLine .getArgs ().length );
324324 assertTrue (commandLine .getArgList ().contains ("-d" ));
325325 assertTrue (commandLine .getArgList ().contains ("arg1" ));
326326 assertTrue (commandLine .getArgList ().contains ("arg2" ));
327327
328- UnrecognizedOptionException e = assertThrows (UnrecognizedOptionException .class , () -> parser .parse (options , args , null , false ));
328+ final UnrecognizedOptionException e = assertThrows (UnrecognizedOptionException .class , () -> parser .parse (options , args , null , false ));
329329 assertTrue (e .getMessage ().contains ("-d" ));
330330 }
331331
0 commit comments