@@ -44,53 +44,47 @@ public void whenStringArrayValueIsList_returnAsArray() {
4444 assertThat (MapUtils .getStringArray (map , "values" ), arrayContaining ("7" , "8" , "true" ));
4545 }
4646
47- @ DisplayName ("Check getBooleanValue for true values" )
47+ @ DisplayName ("After creating a map, check that 'good' true values are correctly interpreted " )
4848 @ Test
49- public void checkGetBooleanForTrueValues () {
50- Map <String , Object > map = new HashMap <>();
51- map .put ("1" , "true" );
52- map .put ("2" , "t" );
53- map .put ("3" , "yes" );
54- map .put ("4" , "on" );
55- map .put ("5" , "y" );
56- map .put ("6" , "truenot" );
57- map .put ("7" , "nottrue" );
58- map .put ("8" , "yesss" );
59- map .put ("9" , "y " );
60- map .put ("10" , " y " );
49+ public void afterCreateMap_checkGoodTrueValues () {
50+ Map <String , Object > map = createMapOfTrueValues ();
6151
6252 assertEquals (true , MapUtils .getBooleanValue (map , "1" ));
6353 assertEquals (true , MapUtils .getBooleanValue (map , "2" ));
6454 assertEquals (true , MapUtils .getBooleanValue (map , "3" ));
6555 assertEquals (true , MapUtils .getBooleanValue (map , "4" ));
6656 assertEquals (true , MapUtils .getBooleanValue (map , "5" ));
57+ }
58+
59+ @ DisplayName ("After creating a map, check that 'bad' true values are correctly interpreted" )
60+ @ Test
61+ public void afterCreateMap_checkBaddTrueValues () {
62+ Map <String , Object > map = createMapOfTrueValues ();
63+
6764 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "6" ));
6865 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "7" ));
6966 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "8" ));
7067 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "9" ));
7168 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "10" ));
7269 }
7370
74- @ DisplayName ("Check getBooleanValue for false values" )
71+ @ DisplayName ("After creating a map, check that 'good' false values are correctly interpreted " )
7572 @ Test
76- public void checkGetBooleanForFalseValues () {
77- Map <String , Object > map = new HashMap <>();
78- map .put ("1" , "false" );
79- map .put ("2" , "f" );
80- map .put ("3" , "no" );
81- map .put ("4" , "off" );
82- map .put ("5" , "n" );
83- map .put ("6" , "falsedata" );
84- map .put ("7" , "sofalse" );
85- map .put ("8" , "ono" );
86- map .put ("9" , "n " );
87- map .put ("10" , " n " );
73+ public void afterCreateMap_checkGoodFalseValues () {
74+ Map <String , Object > map = createMapOfFalseValues ();
8875
8976 assertEquals (false , MapUtils .getBooleanValue (map , "1" ));
9077 assertEquals (false , MapUtils .getBooleanValue (map , "2" ));
9178 assertEquals (false , MapUtils .getBooleanValue (map , "3" ));
9279 assertEquals (false , MapUtils .getBooleanValue (map , "4" ));
9380 assertEquals (false , MapUtils .getBooleanValue (map , "5" ));
81+ }
82+
83+ @ DisplayName ("After creating a map, check that 'bad' false values are correctly interpreted" )
84+ @ Test
85+ public void afterCreateMap_checkBadFalseValues () {
86+ Map <String , Object > map = createMapOfFalseValues ();
87+
9488 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "6" ));
9589 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "7" ));
9690 assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "8" ));
@@ -103,4 +97,34 @@ private Map<String, Object> createMapWithValue(Object value) {
10397 map .put ("values" , value );
10498 return map ;
10599 }
100+
101+ private Map <String , Object > createMapOfTrueValues () {
102+ Map <String , Object > map = new HashMap <>();
103+ map .put ("1" , "true" );
104+ map .put ("2" , "t" );
105+ map .put ("3" , "yes" );
106+ map .put ("4" , "on" );
107+ map .put ("5" , "y" );
108+ map .put ("6" , "truenot" );
109+ map .put ("7" , "nottrue" );
110+ map .put ("8" , "yesss" );
111+ map .put ("9" , "y " );
112+ map .put ("10" , " y " );
113+ return map ;
114+ }
115+
116+ private Map <String , Object > createMapOfFalseValues () {
117+ Map <String , Object > map = new HashMap <>();
118+ map .put ("1" , "false" );
119+ map .put ("2" , "f" );
120+ map .put ("3" , "no" );
121+ map .put ("4" , "off" );
122+ map .put ("5" , "n" );
123+ map .put ("6" , "falsedata" );
124+ map .put ("7" , "sofalse" );
125+ map .put ("8" , "ono" );
126+ map .put ("9" , "n " );
127+ map .put ("10" , " n " );
128+ return map ;
129+ }
106130}
0 commit comments