JsonSerializer implements EntityDocumentDumpProcessor { protected static String jacksonObjectToString(Object object) { try { return mapper.writeValueAsString(object); } catch (JsonProcessingException e) { logger.error("Failed to serialize JSON data: " + e.toString()); return null; } } JsonSerializer(OutputStream outputStream); @Override void open(); @Override void processItemDocument(ItemDocument itemDocument); @Override void processPropertyDocument(PropertyDocument propertyDocument); @Override void processLexemeDocument(LexemeDocument lexemeDocument); @Override void processMediaInfoDocument(MediaInfoDocument mediaInfoDocument); @Override void close(); int getEntityDocumentCount(); static String getJsonString(ItemDocument itemDocument); static String getJsonString(PropertyDocument propertyDocument); static String getJsonString(MediaInfoDocument mediaInfoDocument); static String getJsonString(Statement statement);  }
@Test public void testJacksonObjectToJsonError() { Object obj = new Object() { @SuppressWarnings("unused") public String getData() throws JsonGenerationException { throw new JsonGenerationException("Test exception"); } }; String result = JsonSerializer.jacksonObjectToString(obj); assertNull(result); }