### Question:
XmlTagContentExtractor { public String extractFirstTagContent(String message, String tagName) { Matcher m = createMatcher(message, tagName); String value = null; if (m.find()) { String tagWithValue = m.group(); value = extractValue(tagWithValue, tagName); } return value; }  List<String> extractTagContents(String message, String tagName); String extractFirstTagContent(String message, String tagName);  }### Answer:
@Test public void extractFirstTagContent_ManyTags_Trim() { String idValue1 = "sds232ewdx22sc"; String idValue2 = "sds232ewdxsc"; String idValue3 = "sds232ewdxsc2"; String message = "fdfdffdgvgdrvv<ids>" + idValue1 + "</ids>\n"; message += "<ids>" + idValue2 + " </ids>"; message += "<ids>" + idValue3 + " </ids>d sd sd s d sd s ds d"; assertEquals(idValue1, extractor.extractFirstTagContent(message, "ids")); }
@Test public void extractFirstTagContent_NoTagFound() { String idValue1 = "sds232ewdx22sc"; String idValue2 = "sds232ewdxsc"; String idValue3 = "sds232ewdxsc2"; String message = "fdfdffdgvgdrvv<id>" + idValue1 + "</id>\n"; message += "<id>" + idValue2 + " </id>"; message += "<id>" + idValue3 + " </id>d sd sd s d sd s ds d"; assertNull(extractor.extractFirstTagContent(message, "nonexistenttag")); }