CondenserUtils { public static String generateSteemitMetadata(String content, String[] tags, String app, String format, Map<String, Object> extraMetadata) { Map<String, Object> metadata = new LinkedHashMap<>(); if (tags != null) { metadata.put(TAGS_FIELD_NAME, tags); } List<String> users = extractUsersFromContent(content); if (users != null && !users.isEmpty()) { metadata.put(USERS_FIELD_NAME, users); } List<String> imageArray = new ArrayList<>(); List<String> linksArray = new ArrayList<>(); List<String> links = extractLinksFromContent(content); for (String link : links) { String lcLink = link.toLowerCase(); if (lcLink.endsWith("jpg") || lcLink.endsWith("jpeg") || lcLink.endsWith("png") || lcLink.endsWith("gif")) { imageArray.add(link); } else { linksArray.add(link); } } if (imageArray.size() > 0) { metadata.put(IMAGES_FIELD_NAME, imageArray); } if (linksArray.size() > 0) { metadata.put(LINKS_FIELD_NAME, linksArray); } metadata.put(APP_FIELD_NAME, app); metadata.put(FORMAT_FIELD_NAME, format); if (extraMetadata != null) { for (String key : extraMetadata.keySet()) { key = key.trim(); if (key.isEmpty()) { continue; } metadata.put(key, extraMetadata.get(key)); } } ObjectMapper objectMapper = new ObjectMapper(); try { return objectMapper.writeValueAsString(metadata); } catch (JsonProcessingException e) { throw new RuntimeException("Unable to create JSON metadata string", e); } } private  CondenserUtils(); static List<String> extractLinksFromContent(String content); static List<String> extractUsersFromContent(String content); static String generateSteemitMetadata(String content, String[] tags, String app, String format,
            Map<String, Object> extraMetadata); static String createPermlinkString(String title);  }
@Test public void testGenerateSteemitMetadata() { assertThat(CondenserUtils.generateSteemitMetadata(DUMMY_TEXT_LINKS + DUMMY_TEXT_USER, new String[] { "test", "dontvote" }, "steemj/0.4.1", "markdown", null), equalTo(EXPECTED_JSON)); }