LocalEmojiUtils { public static Map<String, String> getUnicodeEmojis(ObjectMapper objectMapper) { MapType mapType = TypeFactory.defaultInstance() .constructMapType(Map.class, String.class, String.class); try { return objectMapper.readValue(Resources.getResource(Constants.EMOJI_RESOURCE), mapType); } catch (IOException e) { throw new RuntimeException("Can't read emojis", e); } }  static Map<String, String> getUnicodeEmojis(ObjectMapper objectMapper);  }
@Test public void testGetUnicodeEmojis() { ObjectMapper objectMapper = JsonObjectMapperFactory.createObjectMapper(); Map<String, String> emojis = LocalEmojiUtils.getUnicodeEmojis(objectMapper); assertNotNull(emojis); assertFalse(emojis.isEmpty()); }
@Test public void testGetUnicodeEmojis_withException() throws Exception { ObjectMapper objectMapper = mock(ObjectMapper.class); IOException exception = new IOException("test"); when(objectMapper.readValue(any(URL.class), any(JavaType.class))).thenThrow(exception); try { LocalEmojiUtils.getUnicodeEmojis(objectMapper); fail(); } catch (RuntimeException e) { assertEquals(exception, e.getCause()); } }