minor cleanup

This commit is contained in:
DOHA 2018-12-08 14:02:10 +02:00
parent 03e852e747
commit 670e4f348d

View File

@ -98,7 +98,8 @@ public class HashMapComparisonUnitTest {
asiaCapital4.put("Japan", "Osaka"); asiaCapital4.put("Japan", "Osaka");
asiaCapital4.put("China", "Beijing"); asiaCapital4.put("China", "Beijing");
Map<String, Boolean> result = areEqualKeys(asiaCapital3, asiaCapital4); Map<String, Boolean> result = areEqualKeyValues(asiaCapital3, asiaCapital4);
assertEquals(3, result.size()); assertEquals(3, result.size());
assertThat(result, hasEntry("Japan", false)); assertThat(result, hasEntry("Japan", false));
assertThat(result, hasEntry("South Korea", true)); assertThat(result, hasEntry("South Korea", true));
@ -141,10 +142,10 @@ public class HashMapComparisonUnitTest {
MapDifference<String, String> diff = Maps.difference(asia1, asia2); MapDifference<String, String> diff = Maps.difference(asia1, asia2);
Map<String, String> entriesOnlyOnRight = diff.entriesOnlyOnRight(); Map<String, String> entriesOnlyOnRight = diff.entriesOnlyOnRight();
Map<String, String> entriesOnlyOnLeft = diff.entriesOnlyOnLeft();
assertEquals(1, entriesOnlyOnRight.size()); assertEquals(1, entriesOnlyOnRight.size());
assertThat(entriesOnlyOnRight, hasEntry("China", "Beijing")); assertThat(entriesOnlyOnRight, hasEntry("China", "Beijing"));
Map<String, String> entriesOnlyOnLeft = diff.entriesOnlyOnLeft();
assertEquals(1, entriesOnlyOnLeft.size()); assertEquals(1, entriesOnlyOnLeft.size());
assertThat(entriesOnlyOnLeft, hasEntry("South Korea", "Seoul")); assertThat(entriesOnlyOnLeft, hasEntry("South Korea", "Seoul"));
} }
@ -218,7 +219,7 @@ public class HashMapComparisonUnitTest {
.allMatch(e -> Arrays.equals(e.getValue(), second.get(e.getKey()))); .allMatch(e -> Arrays.equals(e.getValue(), second.get(e.getKey())));
} }
private Map<String, Boolean> areEqualKeys(Map<String, String> first, Map<String, String> second) { private Map<String, Boolean> areEqualKeyValues(Map<String, String> first, Map<String, String> second) {
return first.entrySet() return first.entrySet()
.stream() .stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().equals(second.get(e.getKey())))); .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().equals(second.get(e.getKey()))));