Skip to content

Commit 96fbef6

Browse files
anuraggoyal1jzheaux
authored andcommitted
changes as per review (eugenp#6341)
* [BAEL-2471] Guide to Apache Commons MultiValuedMap * Update MultiValuedMapUnitTest.java * added empty lines * updated as per review comments * changes as per review
1 parent 6c237aa commit 96fbef6

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

java-collections-maps/src/test/java/com/baeldung/java/map/MultiValuedMapUnitTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import java.util.Collection;
1010
import java.util.Map;
1111
import java.util.Map.Entry;
12+
import java.util.Set;
1213

1314
import org.apache.commons.collections4.MultiMapUtils;
15+
import org.apache.commons.collections4.MultiSet;
1416
import org.apache.commons.collections4.MultiValuedMap;
1517
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
1618
import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
@@ -65,25 +67,28 @@ public void givenMultiValuesMap_whenUsingEntriesMethod_thenReturningMappings() {
6567
@Test
6668
public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() {
6769
MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();
68-
6970
map.put("fruits", "apple");
7071
map.put("fruits", "orange");
7172
map.put("vehicles", "car");
7273
map.put("vehicles", "bike");
7374

74-
assertThat(((Collection<String>) map.keys())).contains("fruits", "vehicles");
75+
MultiSet<String> keys = map.keys();
76+
77+
assertThat((keys)).contains("fruits", "vehicles");
78+
7579
}
7680

7781
@Test
7882
public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() {
7983
MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();
80-
8184
map.put("fruits", "apple");
8285
map.put("fruits", "orange");
8386
map.put("vehicles", "car");
8487
map.put("vehicles", "bike");
8588

86-
assertThat((Collection<String>) map.keySet()).contains("fruits", "vehicles");
89+
Set<String> keys = map.keySet();
90+
91+
assertThat(keys).contains("fruits", "vehicles");
8792

8893
}
8994

0 commit comments

Comments
 (0)