@Test public void testExtractingTextMultipleNodes_shouldPass() { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<document>" + " <h2> A header</h2>" + " <h2>Just another header</h2>" + "</document>"; assertThat(xml) .nodesByXPath("/document/h2") .extractingText() .containsExactly("A header", "Just another header"); }
public AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText() { isNotNull(); List<String> values = new ArrayList<>(); for (Node node : actual) { String textContent = node.getTextContent(); if (textContent != null) { textContent = textContent.trim(); } values.add(textContent); } String extractedDescription = "Extracted text content"; String description = Description.mostRelevantDescription(this.info.description(), extractedDescription); return newListAssertInstance(values).as(description); }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText() { isNotNull(); List<String> values = new ArrayList<>(); for (Node node : actual) { String textContent = node.getTextContent(); if (textContent != null) { textContent = textContent.trim(); } values.add(textContent); } String extractedDescription = "Extracted text content"; String description = Description.mostRelevantDescription(this.info.description(), extractedDescription); return newListAssertInstance(values).as(description); } }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText() { isNotNull(); List<String> values = new ArrayList<>(); for (Node node : actual) { String textContent = node.getTextContent(); if (textContent != null) { textContent = textContent.trim(); } values.add(textContent); } String extractedDescription = "Extracted text content"; String description = Description.mostRelevantDescription(this.info.description(), extractedDescription); return newListAssertInstance(values).as(description); } private  MultipleNodeAssert(Iterable<Node> nodes, JAXPXPathEngine engine); }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText() { isNotNull(); List<String> values = new ArrayList<>(); for (Node node : actual) { String textContent = node.getTextContent(); if (textContent != null) { textContent = textContent.trim(); } values.add(textContent); } String extractedDescription = "Extracted text content"; String description = Description.mostRelevantDescription(this.info.description(), extractedDescription); return newListAssertInstance(values).as(description); } private  MultipleNodeAssert(Iterable<Node> nodes, JAXPXPathEngine engine); MultipleNodeAssert exist(); void doNotExist(); MultipleNodeAssert haveAttribute(final String attributeName); MultipleNodeAssert haveAttribute(final String attributeName, final String attributeValue); MultipleNodeAssert doNotHaveAttribute(final String attributeName); MultipleNodeAssert doNotHaveAttribute(final String attributeName, final String attributeValue); MultipleNodeAssert containsAnyNodeHavingXPath(String xPath); MultipleNodeAssert containsAllNodesHavingXPath(final String xPath); AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingAttribute(String attribute); AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText(); }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText() { isNotNull(); List<String> values = new ArrayList<>(); for (Node node : actual) { String textContent = node.getTextContent(); if (textContent != null) { textContent = textContent.trim(); } values.add(textContent); } String extractedDescription = "Extracted text content"; String description = Description.mostRelevantDescription(this.info.description(), extractedDescription); return newListAssertInstance(values).as(description); } private  MultipleNodeAssert(Iterable<Node> nodes, JAXPXPathEngine engine); MultipleNodeAssert exist(); void doNotExist(); MultipleNodeAssert haveAttribute(final String attributeName); MultipleNodeAssert haveAttribute(final String attributeName, final String attributeValue); MultipleNodeAssert doNotHaveAttribute(final String attributeName); MultipleNodeAssert doNotHaveAttribute(final String attributeName, final String attributeValue); MultipleNodeAssert containsAnyNodeHavingXPath(String xPath); MultipleNodeAssert containsAllNodesHavingXPath(final String xPath); AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingAttribute(String attribute); AbstractListAssert<?, List<? extends String>, String, ObjectAssert<String>> extractingText();  }