### Question:
HashMapUtil { public static <K, V> HashMap<V, K> reverse(Map<K, V> in) { HashMap<V, K> hm = new HashMap<V, K>(); for (Map.Entry<K, V> e : in.entrySet()) { hm.put(e.getValue(), e.getKey()); } return hm; }  static boolean addHS(Map<K, HashSet<V>> map, K key, V value); static boolean addHS(Map<K, HashSet<V>> map, K key, Iterable<V> value); static boolean addHS(Map<K1, HashMap<K2, HashSet<V>>> map, K1 key1, K2 key2,
          V value); static void addAL(Map<K1, HashMap<K2, ArrayList<V>>> map, K1 key1, K2 key2,
          V value); static void addAL(Map<K, ArrayList<V>> map, K key, V value); static void addAL(Map<K, ArrayList<V>> map, Map<K,V> toAdd); static void addAL2(Map<K1, HashMap<K2, ArrayList<V>>> map, Map<K1, M> toAdd); static V put2(Map<K1, HashMap<K2, V>> map, K1 key1, K2 key2, V value); static HashMap<V, HashSet<K>> reverseHS(Map<K, HashSet<V>> in); static HashMap<V, ArrayList<K>> reverseAL(Map<K, ArrayList<V>> in); static HashMap<V, K> reverse(Map<K, V> in); static HashMap<V, ArrayList<K>> reverseDuplicateValues(Map<K,V> in); static HashMap<K2, HashMap<K1, V>> reverseDouble(Map<K1, M> dblMap); @SafeVarargs static HashMap<K,V> fromPairs(Pair<K,V>... pairs); static HashMap<K,V> fromPairs(Iterable<Pair<K,V>> pairs); static HashMap<K,V> fromArrays(K[] keys, V[] values, int length); static String toString(Map<K,V> map); static int getIndex(Map<K,Integer> k2ndx, K key); static K[] indexToArray(Map<K,Integer> k2ndx, Class<K> clz); static Map<K,Integer> arrayToIndex(K[] arr); static void retainAll(Map<K,?> map, Collection<K> set); static void removeIf(Map<K,V> map, Predicate<Map.Entry<K, V>> removeCondition); static void removeAll(Map<K,?> map, Collection<K> set); static ArrayList<Pair<K,V>> toPairs(Map<K,V> map); static K canonical(Map<K,K> map, K item); static Map<K,Integer> toSortedIndex(Iterable<K> items);  }### Answer:
@Test public void testReverse() { HashMap<TestK, TestV> map = new HashMap<HashMapUtilTest.TestK, HashMapUtilTest.TestV>(); map.put(new TestK("k1"), new TestV("v1")); map.put(new TestK("k1"), new TestV("v1")); map.put(new TestK("k1"), new TestV("v1")); map.put(new TestK("k1"), new TestV("v1")); map.put(new TestK("v1"), new TestV("k1")); map.put(new TestK("v1"), new TestV("k1")); map.put(new TestK("v1"), new TestV("k1")); for (Map.Entry<TestV, TestK> entry: HashMapUtil.reverse(map).entrySet()){ if (entry.getKey().getLabel().equalsIgnoreCase("v1")){ assertTrue((entry.getValue().getLabel().equalsIgnoreCase("k1"))); } if (entry.getKey().getLabel().equalsIgnoreCase("k1")){ assertTrue((entry.getValue().getLabel().equalsIgnoreCase("v1"))); } } }