### Question:
CollectionUtils { public static <O> Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll) { final Map<O, Integer> count = new HashMap<>(); for (final O obj : coll) { count.put(obj, count.getOrDefault(obj, 0) + 1); } return count; } private  CollectionUtils(); static Collection<T> subtract(Set<T> a, Set<T> b); static boolean isNotEmpty(Collection coll); static boolean isEmpty(Collection coll); static Map<String, String> stringToMap(String str, String separator); static Map<String, String> stringToMap(String str, String separator, String keyPrefix); static boolean equalLists(Collection<?> a, Collection<?> b); static boolean isEqualCollection(final Collection<?> a, final Collection<?> b); static Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll); static List<Map<String, Object>> getListByExclusion(List<T> originList, Set<String> exclusionSet);  }### Answer:
@Test public void getCardinalityMap(){ List<Integer> a = new ArrayList<>(); a.add(1); a.add(2); a.add(2); a.add(3); a.add(3); a.add(3); Map<Integer,Integer> cardinalityMap = CollectionUtils.getCardinalityMap(a); Assert.assertEquals(3, cardinalityMap.size()); Assert.assertEquals(1, cardinalityMap.get(1).intValue()); Assert.assertEquals(2, cardinalityMap.get(2).intValue()); Assert.assertEquals(3, cardinalityMap.get(3).intValue()); }