TagHelper { public String safeObjectMapperWriteValueAsString(final TagEntity tagEntity) { String jsonString = ""; try { jsonString = jsonHelper.objectToJson(tagEntity); } catch (IllegalStateException illegalStateException) { LOGGER.warn("Could not parse tagEntity id={" + tagEntity.getId() + "} into JSON string. ", illegalStateException); } return jsonString; }  void executeFunctionForTagEntities(final String indexName, final List<TagEntity> tagEntities,
        final TriConsumer<String, String, String> function); String safeObjectMapperWriteValueAsString(final TagEntity tagEntity); void validateTagKey(TagKey tagKey);  }
@Test public void testSafeObjectMapperWriteValueAsString() { final TagEntity tagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_DESCRIPTION); when(jsonHelper.objectToJson(any())).thenReturn(JSON_STRING); String result = tagHelper.safeObjectMapperWriteValueAsString(tagEntity); verify(jsonHelper).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); assertEquals(JSON_STRING, result); }
@Test public void testSafeObjectMapperWriteValueAsStringJsonParseException() { final TagEntity tagEntity = tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_DESCRIPTION); when(jsonHelper.objectToJson(any())) .thenThrow(new IllegalStateException(new JsonParseException("Failed to Parse", new JsonLocation("SRC", 100L, 1, 2)))); String result = tagHelper.safeObjectMapperWriteValueAsString(tagEntity); verify(jsonHelper).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); assertEquals("", result); }