changes as per review (#6341)
* [BAEL-2471] Guide to Apache Commons MultiValuedMap * Update MultiValuedMapUnitTest.java * added empty lines * updated as per review comments * changes as per review
This commit is contained in:
parent
6c237aaf3a
commit
96fbef6a14
|
@ -9,8 +9,10 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.collections4.MultiMapUtils;
|
import org.apache.commons.collections4.MultiMapUtils;
|
||||||
|
import org.apache.commons.collections4.MultiSet;
|
||||||
import org.apache.commons.collections4.MultiValuedMap;
|
import org.apache.commons.collections4.MultiValuedMap;
|
||||||
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
|
import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
|
||||||
import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
|
import org.apache.commons.collections4.multimap.HashSetValuedHashMap;
|
||||||
|
@ -65,25 +67,28 @@ public class MultiValuedMapUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() {
|
public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() {
|
||||||
MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();
|
MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();
|
||||||
|
|
||||||
map.put("fruits", "apple");
|
map.put("fruits", "apple");
|
||||||
map.put("fruits", "orange");
|
map.put("fruits", "orange");
|
||||||
map.put("vehicles", "car");
|
map.put("vehicles", "car");
|
||||||
map.put("vehicles", "bike");
|
map.put("vehicles", "bike");
|
||||||
|
|
||||||
assertThat(((Collection<String>) map.keys())).contains("fruits", "vehicles");
|
MultiSet<String> keys = map.keys();
|
||||||
|
|
||||||
|
assertThat((keys)).contains("fruits", "vehicles");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() {
|
public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() {
|
||||||
MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();
|
MultiValuedMap<String, String> map = new ArrayListValuedHashMap<>();
|
||||||
|
|
||||||
map.put("fruits", "apple");
|
map.put("fruits", "apple");
|
||||||
map.put("fruits", "orange");
|
map.put("fruits", "orange");
|
||||||
map.put("vehicles", "car");
|
map.put("vehicles", "car");
|
||||||
map.put("vehicles", "bike");
|
map.put("vehicles", "bike");
|
||||||
|
|
||||||
assertThat((Collection<String>) map.keySet()).contains("fruits", "vehicles");
|
Set<String> keys = map.keySet();
|
||||||
|
|
||||||
|
assertThat(keys).contains("fruits", "vehicles");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue