|
9 | 9 | import java.util.Collection; |
10 | 10 | import java.util.Map; |
11 | 11 | import java.util.Map.Entry; |
| 12 | +import java.util.Set; |
12 | 13 |
|
13 | 14 | import org.apache.commons.collections4.MultiMapUtils; |
| 15 | +import org.apache.commons.collections4.MultiSet; |
14 | 16 | import org.apache.commons.collections4.MultiValuedMap; |
15 | 17 | import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; |
16 | 18 | import org.apache.commons.collections4.multimap.HashSetValuedHashMap; |
@@ -65,25 +67,28 @@ public void givenMultiValuesMap_whenUsingEntriesMethod_thenReturningMappings() { |
65 | 67 | @Test |
66 | 68 | public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() { |
67 | 69 | MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>(); |
68 | | - |
69 | 70 | map.put("fruits", "apple"); |
70 | 71 | map.put("fruits", "orange"); |
71 | 72 | map.put("vehicles", "car"); |
72 | 73 | map.put("vehicles", "bike"); |
73 | 74 |
|
74 | | - assertThat(((Collection<String>) map.keys())).contains("fruits", "vehicles"); |
| 75 | + MultiSet<String> keys = map.keys(); |
| 76 | + |
| 77 | + assertThat((keys)).contains("fruits", "vehicles"); |
| 78 | + |
75 | 79 | } |
76 | 80 |
|
77 | 81 | @Test |
78 | 82 | public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() { |
79 | 83 | MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>(); |
80 | | - |
81 | 84 | map.put("fruits", "apple"); |
82 | 85 | map.put("fruits", "orange"); |
83 | 86 | map.put("vehicles", "car"); |
84 | 87 | map.put("vehicles", "bike"); |
85 | 88 |
|
86 | | - assertThat((Collection<String>) map.keySet()).contains("fruits", "vehicles"); |
| 89 | + Set<String> keys = map.keySet(); |
| 90 | + |
| 91 | + assertThat(keys).contains("fruits", "vehicles"); |
87 | 92 |
|
88 | 93 | } |
89 | 94 |
|
|
0 commit comments