### Question:
XmlTagContentExtractor { public List<String> extractTagContents(String message, String tagName) { List<String> ids = Lists.newArrayList(); Matcher m = createMatcher(message, tagName); while(m.find()) { String tagWithValue = m.group(); String value = extractValue(tagWithValue, tagName); ids.add(value); } return ids; }  List<String> extractTagContents(String message, String tagName); String extractFirstTagContent(String message, String tagName);  }### Answer:
@Test public void extractTagContents_OneTag() { String idValue = "sds232ewdxsc"; String message = "<id>" + idValue + "</id>"; assertExtractedIds(extractor.extractTagContents(message, "id"), idValue); }
@Test public void extractTagContents_ManyTags() { String idValue1 = "sds232ewdxsc"; String idValue2 = "sds232ewdxsc"; String idValue3 = "sds232ewdxsc2"; String message = "<id>" + idValue1 + "</id>\n"; message += "<id>" + idValue2 + "</id>"; message += "<id>" + idValue3 + "</id>"; assertExtractedIds(extractor.extractTagContents(message, "id"), idValue1, idValue2, idValue3); }
@Test public void extractTagContents_ManyTags_Trim() { String idValue1 = "sds232ewdxsc"; 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"; assertExtractedIds(extractor.extractTagContents(message, "id"), idValue1, idValue2, idValue3); }