|
4 | 4 |
|
5 | 5 | package weblogic.logging.exporter.config; |
6 | 6 |
|
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; |
15 | 15 |
|
16 | 16 | @SuppressWarnings("EmptyMethod") |
17 | 17 | 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 | + } |
49 | 49 | } |
0 commit comments