TagGroupUtils { @NonNull public static Map<String, Set<String>> union(@NonNull Map<String, Set<String>> lh, @NonNull Map<String, Set<String>> rh) { Map<String, Set<String>> result = new HashMap<>(); addAll(result, lh); addAll(result, rh); return result; }  @NonNull static Map<String, Set<String>> union(@NonNull Map<String, Set<String>> lh, @NonNull Map<String, Set<String>> rh); static void addAll(@NonNull Map<String, Set<String>> lh, @NonNull Map<String, Set<String>> rh); static boolean containsAll(@NonNull Map<String, Set<String>> lh, @NonNull Map<String, Set<String>> rh); @NonNull static Map<String, Set<String>> intersect(@NonNull Map<String, Set<String>> lh, @NonNull Map<String, Set<String>> rh); @NonNull static Map<String, Set<String>> parseTags(@Nullable JsonValue value);  }
@Test public void testUnion() { Map<String, Set<String>> tagGroupsOne = new HashMap<>(); tagGroupsOne.put("shared-group", tagSet("cool", "awesome")); tagGroupsOne.put("unique-group", tagSet("nice", "amazing")); Map<String, Set<String>> tagGroupsTwo = new HashMap<>(); tagGroupsTwo.put("shared-group", tagSet("rad")); Map<String, Set<String>> expected = new HashMap<>(); expected.put("shared-group", tagSet("cool", "awesome", "rad")); expected.put("unique-group", tagSet("nice", "amazing")); assertEquals(expected, TagGroupUtils.union(tagGroupsOne, tagGroupsTwo)); assertEquals(expected, TagGroupUtils.union(tagGroupsTwo, tagGroupsOne)); }