@@ -44,53 +44,47 @@ public void whenStringArrayValueIsList_returnAsArray() {
44
44
assertThat (MapUtils .getStringArray (map , "values" ), arrayContaining ("7" , "8" , "true" ));
45
45
}
46
46
47
- @ DisplayName ("Check getBooleanValue for true values" )
47
+ @ DisplayName ("After creating a map, check that 'good' true values are correctly interpreted " )
48
48
@ 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 ();
61
51
62
52
assertEquals (true , MapUtils .getBooleanValue (map , "1" ));
63
53
assertEquals (true , MapUtils .getBooleanValue (map , "2" ));
64
54
assertEquals (true , MapUtils .getBooleanValue (map , "3" ));
65
55
assertEquals (true , MapUtils .getBooleanValue (map , "4" ));
66
56
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
+
67
64
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "6" ));
68
65
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "7" ));
69
66
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "8" ));
70
67
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "9" ));
71
68
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "10" ));
72
69
}
73
70
74
- @ DisplayName ("Check getBooleanValue for false values" )
71
+ @ DisplayName ("After creating a map, check that 'good' false values are correctly interpreted " )
75
72
@ 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 ();
88
75
89
76
assertEquals (false , MapUtils .getBooleanValue (map , "1" ));
90
77
assertEquals (false , MapUtils .getBooleanValue (map , "2" ));
91
78
assertEquals (false , MapUtils .getBooleanValue (map , "3" ));
92
79
assertEquals (false , MapUtils .getBooleanValue (map , "4" ));
93
80
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
+
94
88
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "6" ));
95
89
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "7" ));
96
90
assertThrows (ConfigurationException .class , () -> MapUtils .getBooleanValue (map , "8" ));
@@ -103,4 +97,34 @@ private Map<String, Object> createMapWithValue(Object value) {
103
97
map .put ("values" , value );
104
98
return map ;
105
99
}
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
+ }
106
130
}
0 commit comments