@@ -22,6 +22,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2222import static org .junit .Assert .assertNull ;
2323
2424import java .util .Properties ;
25+ import java .util .function .Supplier ;
2526
2627import org .junit .Test ;
2728
@@ -150,6 +151,18 @@ public void testGetParsedOptionValueWithChar() throws Exception {
150151 assertEquals ("foo" , cmd .getParsedOptionValue ('f' ));
151152 }
152153
154+ @ Test
155+ public void testGetParsedOptionValueWithNullSupplier () throws Exception {
156+ final Options options = new Options ();
157+ options .addOption (Option .builder ("i" ).hasArg ().type (Number .class ).build ());
158+
159+ final CommandLineParser parser = new DefaultParser ();
160+ final CommandLine cmd = parser .parse (options , new String [0 ]);
161+ final Supplier <Number > supplier = null ;
162+
163+ assertNull (cmd .getParsedOptionValue ('i' , supplier ));
164+ }
165+
153166 @ Test
154167 public void testGetParsedOptionValueWithOption () throws Exception {
155168 final Options options = new Options ();
@@ -178,11 +191,11 @@ public void testGetParsedOptionValueUsingDefault() throws Exception {
178191
179192 assertEquals (123 , ((Number ) cmd .getParsedOptionValue (optI )).intValue ());
180193 assertEquals ("foo" , cmd .getParsedOptionValue (optF , "foo" ));
181- assertEquals ("foo" , cmd .getParsedOptionValue (optF , ()-> "foo" ));
194+ assertEquals ("foo" , cmd .getParsedOptionValue (optF , () -> "foo" ));
182195 assertEquals ("foo" , cmd .getParsedOptionValue ("f" , "foo" ));
183- assertEquals ("foo" , cmd .getParsedOptionValue ("f" , ()-> "foo" ));
196+ assertEquals ("foo" , cmd .getParsedOptionValue ("f" , () -> "foo" ));
184197 assertEquals ("foo" , cmd .getParsedOptionValue ('f' , "foo" ));
185- assertEquals ("foo" , cmd .getParsedOptionValue ('f' , ()-> "foo" ));
198+ assertEquals ("foo" , cmd .getParsedOptionValue ('f' , () -> "foo" ));
186199 }
187200
188201 @ Test
0 commit comments