Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit c4894b5

Browse files
committed
some updates based on review feedback
1 parent cf582f1 commit c4894b5

File tree

3 files changed

+58
-56
lines changed

3 files changed

+58
-56
lines changed

src/test/java/weblogic/logging/exporter/FirstTest.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/test/java/weblogic/logging/exporter/ResultTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@
1414
@DisplayName("Test the Result object")
1515
public class ResultTest {
1616

17+
// using 200 for status field just to test it is set/got correctly
18+
// 200 is HTTP status for OK
1719
private static final String EXPECTED_STRING =
18-
"Result{response='good', status=1, successful=true}";
20+
"Result{response='good', status=200, successful=true}";
1921

20-
@DisplayName("Check constructor and getters")
22+
@DisplayName("After creating a Result, make sure I can retrieve the field values")
2123
@Test
22-
public void testConstructorAndGetters() {
23-
Result result = new Result("good", 1, true);
24+
public void afterCreated_canRetrieveFieldValues() {
25+
Result result = new Result("good", 200, true);
2426

2527
assertEquals("good", result.getResponse());
26-
assertEquals(1, result.getStatus());
28+
assertEquals(200, result.getStatus());
2729
assertEquals(true, result.isSuccessful());
2830
}
2931

3032
@DisplayName("Check toString() works")
3133
@Test
3234
public void checkToString() {
33-
Result result = new Result("good", 1, true);
35+
Result result = new Result("good", 200, true);
3436

3537
assertEquals(EXPECTED_STRING, result.toString());
3638
}

src/test/java/weblogic/logging/exporter/config/MapUtilsTest.java

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)