### Question:
XMLUtil extends AbstractCaller { @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 public String getValueByXPath(String content, String xpath) { NodeList nodes = getNodesByXPath(content, xpath); if (nodes.getLength() != 1 || !hasOnlyTextNode(nodes.item(0))) { throw new EPSCommonException("The node has child nodes." + System.lineSeparator() + nodeToString(nodes.item(0))); } return nodes.item(0).getTextContent(); }  @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 testGetValueByXPath() { String value = xmlUtil.getValueByXPath(XML_EXAMPLE, "A/C/D"); Assert.assertEquals("Test!", value); }
@Test(expected = EPSCommonException.class) public void testGetValueByXPathException() { String value = xmlUtil.getValueByXPath(XML_EXAMPLE, "A/C"); }
@Test(expected = EPSCommonException.class) public void testSetValueByXPathException() { String value = xmlUtil.getValueByXPath(XML_EXAMPLE, "A/C"); }