### Question:
XMLUtil extends AbstractCaller { @Description("Returns a list values by xpath.<br>" + "<b>content</b> - xml document<br>" + "<b>xpath</b> - path to list<br>" + "Example:<br/>" + "#{getListByXPath(content, xpath)}") @UtilityMethod public List<String> getListByXPath(String content, String xpath) { NodeList nodes = getNodesByXPath(content, xpath); if (nodes.getLength() == 0) { return Collections.emptyList(); } List<String> result = new ArrayList<>(); for(Node elem : nodeListToList(nodes, x -> x.getNodeType() != Node.COMMENT_NODE)) { if (!hasOnlyTextNode(elem)) { throw new EPSCommonException("The node has child nodes." + System.lineSeparator() + nodeToString(elem)); } result.add(elem.getTextContent()); } return result; }  @Description("Returns a xml document with new value of selected node.<br>" + "<b>content</b> - xml document<br>" + "<b>xpath</b> - path to node<br>" + "<b>value</b> - new value of node<br>" + "Example:<br/>" + "#{setValueByXPath(content, xpath, value)}") @UtilityMethod String setValueByXPath(String content, String xpath, String value); @Description("Returns a value of node by xpath.<br>" + "<b>content</b> - xml document<br>" + "<b>xpath</b> - path to node<br>" + "Example:<br/>" + "#{getObjectByXPath(content, xpath)}") @UtilityMethod String getValueByXPath(String content, String xpath); @Description("Returns a object by xpath.<br>" + "<b>content</b> - xml document<br>" + "<b>xpath</b> - path to object<br>" + "Example:<br/>" + "#{getObjectByXPath(content, xpath)}") @UtilityMethod Map<String, ?> getObjectByXPath(String content, String xpath); @Description("Returns a list values by xpath.<br>" + "<b>content</b> - xml document<br>" + "<b>xpath</b> - path to list<br>" + "Example:<br/>" + "#{getListByXPath(content, xpath)}") @UtilityMethod List<String> getListByXPath(String content, String xpath);  }### Answer:
@Test public void testGetListByXPath() { List<String> list = xmlUtil.getListByXPath(XML_EXAMPLE, "A/B"); Assert.assertEquals(Arrays.asList("value1", "value2"), list); }
@Test(expected = EPSCommonException.class) public void testGetListByXPathException() { List<String> list = xmlUtil.getListByXPath(XML_EXAMPLE, "A/C"); }