@Test public void testContainsAnyNodeHavingXPath_shouldFailed() { thrown.expectAssertionError(format("Expecting:%nany node in set have XPath: <self::node()[@attrA]>")); String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<feed>" + " <title>title</title>" + " <entry attr=\"value\">" + " <title>title1</title>" + " </entry>" + " <entry attr2=\"value2\">" + " <title>title1</title>" + " </entry>" + "</feed>"; assertThat(xml) .hasXPath("/feed/entry") .containsAnyNodeHavingXPath("self::node()[@attrA]"); }
public MultipleNodeAssert containsAnyNodeHavingXPath(String xPath) { isNotNull(); int index = 0; for (Node node : actual) { final SingleNodeAssert singleNodeAssert = toAssert(node, navigationDescription("check node at index " + index)); if (!singleNodeAssert.isNodeSetEmpty(xPath)) { return this; } index++; } throwAssertionError(shouldAnyNodeHaveXPath(xPath)); return null; }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public MultipleNodeAssert containsAnyNodeHavingXPath(String xPath) { isNotNull(); int index = 0; for (Node node : actual) { final SingleNodeAssert singleNodeAssert = toAssert(node, navigationDescription("check node at index " + index)); if (!singleNodeAssert.isNodeSetEmpty(xPath)) { return this; } index++; } throwAssertionError(shouldAnyNodeHaveXPath(xPath)); return null; } }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public MultipleNodeAssert containsAnyNodeHavingXPath(String xPath) { isNotNull(); int index = 0; for (Node node : actual) { final SingleNodeAssert singleNodeAssert = toAssert(node, navigationDescription("check node at index " + index)); if (!singleNodeAssert.isNodeSetEmpty(xPath)) { return this; } index++; } throwAssertionError(shouldAnyNodeHaveXPath(xPath)); return null; } private  MultipleNodeAssert(Iterable<Node> nodes, JAXPXPathEngine engine); }
MultipleNodeAssert extends FactoryBasedNavigableIterableAssert<MultipleNodeAssert, Iterable<Node>, Node, SingleNodeAssert> { public MultipleNodeAssert containsAnyNodeHavingXPath(String xPath) { isNotNull(); int index = 0; for (Node node : actual) { final SingleNodeAssert singleNodeAssert = toAssert(node, navigationDescription("check node at index " + index)); if (!singleNodeAssert.isNodeSetEmpty(xPath)) { return this; } index++; } throwAssertionError(shouldAnyNodeHaveXPath(xPath)); return null; } 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 MultipleNodeAssert containsAnyNodeHavingXPath(String xPath) { isNotNull(); int index = 0; for (Node node : actual) { final SingleNodeAssert singleNodeAssert = toAssert(node, navigationDescription("check node at index " + index)); if (!singleNodeAssert.isNodeSetEmpty(xPath)) { return this; } index++; } throwAssertionError(shouldAnyNodeHaveXPath(xPath)); return null; } 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();  }