ResourceInfo { public String toJson(ObjectMapper objectMapper) { try { return objectMapper.writeValueAsString(this); } catch (IOException ex) { logger.error("Error while writing ResourceInfo object to JSON: {}", this, ex); return null; } } @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)  ResourceInfo(@JsonProperty("url") String url, @JsonProperty("type") String type, @JsonProperty("status") Integer status, @JsonProperty("lastChecked") Long lastChecked); Integer getStatus(); String getType(); String getUrl(); Long getLastChecked(); @Override String toString(); String toJson(ObjectMapper objectMapper); static ResourceInfo fromJson(ObjectMapper objectMapper, String json);  }
@Test public void testToJson() { final String result = RESOURCE_INFO.toJson(objectMapper); assertNotNull(result); assertTrue(result.contains("\"url\":")); assertTrue(result.contains("urlValue")); assertTrue(result.contains("\"type\":")); assertTrue(result.contains("typeValue")); assertTrue(result.contains("\"status\":")); assertTrue(result.contains("999")); assertTrue(result.contains("\"lastChecked\"")); assertTrue(result.contains(Long.toString(LAST_CHECKED_TIME))); }