### Question:
CollectionUtils { public static <K, V> Map<V, K> invertMap(final Map<K, V> map) { Reject.ifNull(map); final Map<V, K> newMap = new HashMap<V, K>(map.size()); for (Map.Entry<K, V> entry : map.entrySet()) { newMap.put(entry.getValue(), entry.getKey()); } return newMap; } private  CollectionUtils(); static Set<String> removeBlankEntries(Set<String> originalSet); static List<T> asList(T... values); static Set asCaseInsensitiveHashSet(Object... values); static Set<T> asSet(T... values); static LinkedHashSet<T> asOrderedSet(T... values); static Map<V, K> invertMap(final Map<K, V> map); static Map<K, M> transformMap(final Map<K, I> map,
                                                                        final Function<I, M, E> mapper); static List<M> transformList(final Collection<I> values,
                                                                    final Function<I, M, E> mapper); static Set<M> transformSet(final Collection<I> values,
                                                                  final Function<I, M, E> mapper); static T getFirstItem(final Collection<T> collection); static T getFirstItem(final Collection<T> collection, final T defaultValue); static boolean genericCompare(T valA, T valB); static boolean compareCaseInsensitiveMapOfSetOfStrings(Map<String, Set<String>> valA,
            Map<String, Set<String>> valB); static int createHashForCaseInsensitiveMapOfSetOfStrings(Map<String, Set<String>> map); static boolean isNotEmpty(final Collection<?> collection); static boolean isEmpty(Collection<?> collection); static Map<String, Set<String>> toAvPairMap(final Set<String> names, final String value); static boolean isEmpty(Map<?, ?> map); static boolean isNotEmpty(Map<?, ?> map); static boolean anyHaveEntries(Object... containers); static Map<K, V> sortMapByValue(Map<K, V> map);  }### Answer:
@Test public void canInvertMap() { Map<Integer, String> numbers = new HashMap<Integer, String>(); numbers.put(1, "one"); numbers.put(2, "two"); numbers.put(3, "three"); Map<String, Integer> invertedNumbers = CollectionUtils.invertMap(numbers); assertThat(invertedNumbers).isNotSameAs(numbers); assertThat(invertedNumbers.size()).isEqualTo(3); assertThat(invertedNumbers.get("one")).isEqualTo(1); assertThat(invertedNumbers.get("two")).isEqualTo(2); assertThat(invertedNumbers.get("three")).isEqualTo(3); }
@Test(expectedExceptions = NullPointerException.class) public void canInvertMapRequiresNonNullMap() { CollectionUtils.invertMap(null); }