|
4 | 4 | import org.apache.commons.collections4.MapUtils; |
5 | 5 | import org.apache.commons.collections4.PredicateUtils; |
6 | 6 | import org.apache.commons.collections4.TransformerUtils; |
| 7 | +import org.assertj.core.api.Assertions; |
7 | 8 | import org.junit.Before; |
8 | 9 | import org.junit.Test; |
9 | 10 |
|
10 | 11 | import java.io.ByteArrayOutputStream; |
11 | 12 | import java.io.PrintStream; |
| 13 | +import java.util.Collection; |
12 | 14 | import java.util.HashMap; |
13 | 15 | import java.util.Map; |
| 16 | +import java.util.Set; |
14 | 17 |
|
| 18 | +import static org.hamcrest.CoreMatchers.not; |
| 19 | +import static org.hamcrest.Matchers.equalTo; |
15 | 20 | import static org.hamcrest.Matchers.is; |
16 | 21 | import static org.hamcrest.collection.IsMapContaining.hasEntry; |
17 | 22 | import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; |
@@ -85,19 +90,12 @@ public void whenGetOnNullMap_thenMustReturnDefaultValue() { |
85 | 90 | @Test |
86 | 91 | public void whenInvertMap_thenMustReturnInvertedMap() { |
87 | 92 | Map<String, String> invColorMap = MapUtils.invertMap(this.colorMap); |
88 | | - assertEquals(this.colorMap.size(), invColorMap.size()); |
89 | 93 |
|
90 | | - MapIterator<String, String> itColorMap |
91 | | - = MapUtils.iterableMap(this.colorMap).mapIterator(); |
92 | | - |
93 | | - while (itColorMap.hasNext()) { |
94 | | - String colorMapKey = itColorMap.next(); |
95 | | - String colorMapValue = itColorMap.getValue(); |
96 | | - |
97 | | - String invColorMapValue = MapUtils.getString(invColorMap, colorMapValue); |
98 | | - |
99 | | - assertTrue(invColorMapValue.equals(colorMapKey)); |
100 | | - } |
| 94 | + int size = invColorMap.size(); |
| 95 | + Assertions.assertThat(invColorMap) |
| 96 | + .hasSameSizeAs(colorMap) |
| 97 | + .containsKeys(this.colorMap.values().toArray(new String[size])) |
| 98 | + .containsValues(this.colorMap.keySet().toArray(new String[size])); |
101 | 99 | } |
102 | 100 |
|
103 | 101 | @Test(expected = IllegalArgumentException.class) |
|
0 commit comments