1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertIterableEquals;
@Test @DisplayName("should merge multiple map when given two map has grouped by") void mergeTwoGroupedMapCollection() { MergedCollection mergedCollection = MergedCollection.builder().build(); Map<String, List<Object>> groupedOne = Maps.newHashMap(); groupedOne.put("a", Lists.newArrayList("a1", "a2", "a3")); groupedOne.put("b", Lists.newArrayList("b1", "b2", "b3")); groupedOne.put("c", Lists.newArrayList("c1", "c2", "c3"));
Map<String, List<Object>> groupedTwo = Maps.newHashMap(); groupedTwo.put("c", Lists.newArrayList("c3", "c4", "c5", "c6", "c7"));
Map<String, List<Object>> newGrouped = mergedCollection.mergeTwoGroupedMapCollection(groupedOne, groupedTwo); List<Object> except_a = ImmutableList.of("a1", "a2", "a3"); List<Object> except_b = ImmutableList.of("b1", "b2", "b3"); List<Object> except_c = ImmutableList.of("c1", "c2", "c3", "c3", "c4", "c5", "c6", "c7"); assertAll("all elements", ()->assertIterableEquals(except_a, newGrouped.get("a")), ()->assertIterableEquals(except_b, newGrouped.get("b")), ()->assertIterableEquals(except_c, newGrouped.get("c")) );
|