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

Commit 5163549

Browse files
committed
update old tests to junit 5
1 parent 58991fe commit 5163549

File tree

2 files changed

+45
-39
lines changed

2 files changed

+45
-39
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@
151151
<version>5.4.1</version>
152152
<scope>test</scope>
153153
</dependency>
154+
<dependency>
155+
<groupId>org.hamcrest</groupId>
156+
<artifactId>hamcrest-junit</artifactId>
157+
<version>2.0.0.0</version>
158+
<scope>test</scope>
159+
</dependency>
154160
<dependency>
155161
<groupId>org.yaml</groupId>
156162
<artifactId>snakeyaml</artifactId>

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

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,46 @@
44

55
package weblogic.logging.exporter.config;
66

7-
// import static org.hamcrest.Matchers.arrayContaining;
8-
// import static org.hamcrest.junit.MatcherAssert.assertThat;
9-
//
10-
// import java.util.Arrays;
11-
// import java.util.HashMap;
12-
// import java.util.Map;
13-
// import org.junit.Before;
14-
// import org.junit.Test;
7+
import static org.hamcrest.Matchers.arrayContaining;
8+
import static org.hamcrest.junit.MatcherAssert.assertThat;
9+
10+
import java.util.Arrays;
11+
import java.util.HashMap;
12+
import java.util.Map;
13+
import org.junit.jupiter.api.BeforeAll;
14+
import org.junit.jupiter.api.Test;
1515

1616
@SuppressWarnings("EmptyMethod")
1717
public class MapUtilsTest {
18-
//
19-
// @Before
20-
// public void setUp() {}
21-
//
22-
// @Test
23-
// public void whenStringArrayValueIsStringArray_returnAsIs() {
24-
// final String[] STRING_ARRAY = {"1", "2", "3"};
25-
// Map<String, Object> map = createMapWithValue(STRING_ARRAY);
26-
//
27-
// assertThat(MapUtils.getStringArray(map, "values"), arrayContaining(STRING_ARRAY));
28-
// }
29-
//
30-
// @Test
31-
// public void whenStringArrayValueIsSingleObject_returnAsLengthOneArray() {
32-
// Map<String, Object> map = createMapWithValue(33);
33-
//
34-
// assertThat(MapUtils.getStringArray(map, "values"), arrayContaining("33"));
35-
// }
36-
//
37-
// @Test
38-
// public void whenStringArrayValueIsList_returnAsArray() {
39-
// Map<String, Object> map = createMapWithValue(Arrays.asList(7, 8, true));
40-
//
41-
// assertThat(MapUtils.getStringArray(map, "values"), arrayContaining("7", "8", "true"));
42-
// }
43-
//
44-
// private Map<String, Object> createMapWithValue(Object value) {
45-
// Map<String, Object> map = new HashMap<>();
46-
// map.put("values", value);
47-
// return map;
48-
// }
18+
19+
@BeforeAll
20+
public static void setUp() {}
21+
22+
@Test
23+
public void whenStringArrayValueIsStringArray_returnAsIs() {
24+
final String[] STRING_ARRAY = {"1", "2", "3"};
25+
Map<String, Object> map = createMapWithValue(STRING_ARRAY);
26+
27+
assertThat(MapUtils.getStringArray(map, "values"), arrayContaining(STRING_ARRAY));
28+
}
29+
30+
@Test
31+
public void whenStringArrayValueIsSingleObject_returnAsLengthOneArray() {
32+
Map<String, Object> map = createMapWithValue(33);
33+
34+
assertThat(MapUtils.getStringArray(map, "values"), arrayContaining("33"));
35+
}
36+
37+
@Test
38+
public void whenStringArrayValueIsList_returnAsArray() {
39+
Map<String, Object> map = createMapWithValue(Arrays.asList(7, 8, true));
40+
41+
assertThat(MapUtils.getStringArray(map, "values"), arrayContaining("7", "8", "true"));
42+
}
43+
44+
private Map<String, Object> createMapWithValue(Object value) {
45+
Map<String, Object> map = new HashMap<>();
46+
map.put("values", value);
47+
return map;
48+
}
4949
}

0 commit comments

Comments
 (0)