### Question:
Util { public static <T, E> T getKeyByValue(Map<T, E> map, E value) { for (Map.Entry<T, E> entry : map.entrySet()) { if (Objects.equals(value, entry.getValue())) { return entry.getKey(); } } return null; }  static T getKeyByValue(Map<T, E> map, E value);  }### Answer:
@Test public void shouldReturnKeyByValue() { Map<String, String> map = new HashMap<>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); String key = Util.getKeyByValue(map, "value1"); assertEquals("key1", key); }
@Test public void shouldReturnNullWhenValueNotPresent() { Map<String, String> map = new HashMap<>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); String key = Util.getKeyByValue(map, "value4"); assertNull(key); }