@ -72,21 +72,25 @@ public class TomlConfigFileDefaultProviderTest {
new TomlConfigFileDefaultProvider ( mockCommandLine , tempConfigFile ) ;
// this option must be found in config
assertThat ( providerUnderTest . defaultValue ( OptionSpec . builder ( "a-short-option" ) . build ( ) ) )
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "a-short-option" ) . type ( Integer . class ) . build ( ) ) )
. isEqualTo ( "123" ) ;
// this option must be found in config as one of its names is present in the file.
// also this is the shortest one.
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "a-short-option" , "another-name-for-the-option" ) . build ( ) ) )
OptionSpec . builder ( "a-short-option" , "another-name-for-the-option" )
. type ( Integer . class )
. build ( ) ) )
. isEqualTo ( "123" ) ;
// this option must be found in config as one of its names is present in the file.
// also this is the longest one.
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "l" , "longer" , "a-longer-option" ) . build ( ) ) )
OptionSpec . builder ( "l" , "longer" , "a-longer-option" ) . type ( Integer . class ) . build ( ) ) )
. isEqualTo ( "1234" ) ;
}
}
@ -97,8 +101,11 @@ public class TomlConfigFileDefaultProviderTest {
Map < String , OptionSpec > validOptionsMap = new HashMap < > ( ) ;
validOptionsMap . put ( "--a-boolean-option" , null ) ;
validOptionsMap . put ( "--another-boolean-option" , null ) ;
validOptionsMap . put ( "--a-primitive-boolean-option" , null ) ;
validOptionsMap . put ( "--another-primitive-boolean-option" , null ) ;
validOptionsMap . put ( "--a-multi-value-option" , null ) ;
validOptionsMap . put ( "--an-int-value-option" , null ) ;
validOptionsMap . put ( "--a-primitive-int-value-option" , null ) ;
validOptionsMap . put ( "--a-wei-value-option" , null ) ;
validOptionsMap . put ( "--a-string-value-option" , null ) ;
validOptionsMap . put ( "--a-nested-multi-value-option" , null ) ;
@ -113,10 +120,16 @@ public class TomlConfigFileDefaultProviderTest {
fileWriter . newLine ( ) ;
fileWriter . write ( "another-boolean-option=false" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "a-primitive-boolean-option=true" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "another-primitive-boolean-option=false" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "a-multi-value-option=[\"value1\", \"value2\"]" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "an-int-value-option=123" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "a-primitive-int-value-option=456" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "a-wei-value-option=1" ) ;
fileWriter . newLine ( ) ;
fileWriter . write ( "a-string-value-option='my value'" ) ;
@ -138,6 +151,18 @@ public class TomlConfigFileDefaultProviderTest {
OptionSpec . builder ( "another-boolean-option" ) . type ( Boolean . class ) . build ( ) ) )
. isEqualTo ( "false" ) ;
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "a-primitive-boolean-option" ) . type ( boolean . class ) . build ( ) ) )
. isEqualTo ( "true" ) ;
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "another-primitive-boolean-option" )
. type ( boolean . class )
. build ( ) ) )
. isEqualTo ( "false" ) ;
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "a-multi-value-option" ) . type ( Collection . class ) . build ( ) ) )
@ -148,6 +173,11 @@ public class TomlConfigFileDefaultProviderTest {
OptionSpec . builder ( "an-int-value-option" ) . type ( Integer . class ) . build ( ) ) )
. isEqualTo ( "123" ) ;
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "a-primitive-int-value-option" ) . type ( int . class ) . build ( ) ) )
. isEqualTo ( "456" ) ;
assertThat (
providerUnderTest . defaultValue (
OptionSpec . builder ( "a-wei-value-option" ) . type ( Wei . class ) . build ( ) ) )