/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code>, with any content. * <p/> * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre> * * @param xPath * the target xpath */ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath) { return org.hamcrest.xml.HasXPath.hasXPath(xPath); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code> within the specified namespace context, with any content. * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes */ public static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext) { return new HasXPath(xPath, namespaceContext, WITH_ANY_CONTENT, XPathConstants.NODE); } }
private HasXPath(String xPathExpression, NamespaceContext namespaceContext, Matcher<String> valueMatcher, QName mode) { this.compiledXPath = compiledXPath(xPathExpression, namespaceContext); this.xpathString = xPathExpression; this.valueMatcher = valueMatcher; this.evaluationMode = mode; }
@Override public boolean matchesSafely(Node item, Description mismatch) { return evaluated(item, mismatch) .and(NODE_EXISTS) .matching(valueMatcher); }
@Override public boolean matchesSafely(Node item, Description mismatch) { return evaluated(item, mismatch) .and(NODE_EXISTS) .matching(valueMatcher); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code> within the specified namespace context, with any content. * <p/> * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes */ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext) { return org.hamcrest.xml.HasXPath.hasXPath(xPath, namespaceContext); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the * specified <code>xPath</code>, within the specified <code>namespaceContext</code>, that satisfies * the specified <code>valueMatcher</code>. * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs, equalTo("Cheddar")))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes * @param valueMatcher * matcher for the value at the specified xpath */ public static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext, Matcher<String> valueMatcher) { return new HasXPath(xPath, namespaceContext, valueMatcher, STRING); }
@Override public boolean matchesSafely(Node item, Description mismatch) { return evaluated(item, mismatch) .and(NODE_EXISTS) .matching(valueMatcher); }
private HasXPath(String xPathExpression, NamespaceContext namespaceContext, Matcher<String> valueMatcher, QName mode) { this.compiledXPath = compiledXPath(xPathExpression, namespaceContext); this.xpathString = xPathExpression; this.valueMatcher = valueMatcher; this.evaluationMode = mode; }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the * specified <code>xPath</code> that satisfies the specified <code>valueMatcher</code>. * <p/> * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", equalTo("Cheddar")))</pre> * * @param xPath * the target xpath * @param valueMatcher * matcher for the value at the specified xpath */ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, org.hamcrest.Matcher<java.lang.String> valueMatcher) { return org.hamcrest.xml.HasXPath.hasXPath(xPath, valueMatcher); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code> within the specified namespace context, with any content. * <p/> * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes */ @Factory public static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext) { return new HasXPath(xPath, namespaceContext, WITH_ANY_CONTENT, XPathConstants.NODE); } }
@Override public boolean matchesSafely(Node item, Description mismatch) { return evaluated(item, mismatch) .and(NODE_EXISTS) .matching(valueMatcher); }
private HasXPath(String xPathExpression, NamespaceContext namespaceContext, Matcher<String> valueMatcher, QName mode) { this.compiledXPath = compiledXPath(xPathExpression, namespaceContext); this.xpathString = xPathExpression; this.valueMatcher = valueMatcher; this.evaluationMode = mode; }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code>, with any content. * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre> * * @param xPath * the target xpath */ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath) { return org.hamcrest.xml.HasXPath.hasXPath(xPath); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the * specified <code>xPath</code>, within the specified <code>namespaceContext</code>, that satisfies * the specified <code>valueMatcher</code>. * <p/> * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs, equalTo("Cheddar")))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes * @param valueMatcher * matcher for the value at the specified xpath */ @Factory public static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext, Matcher<String> valueMatcher) { return new HasXPath(xPath, namespaceContext, valueMatcher, STRING); }
private HasXPath(String xPathExpression, NamespaceContext namespaceContext, Matcher<String> valueMatcher, QName mode) { this.compiledXPath = compiledXPath(xPathExpression, namespaceContext); this.xpathString = xPathExpression; this.valueMatcher = valueMatcher; this.evaluationMode = mode; }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the * specified <code>xPath</code>, within the specified <code>namespaceContext</code>, that satisfies * the specified <code>valueMatcher</code>. * <p/> * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs, equalTo("Cheddar")))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes * @param valueMatcher * matcher for the value at the specified xpath */ public static org.hamcrest.Matcher<org.w3c.dom.Node> hasXPath(java.lang.String xPath, javax.xml.namespace.NamespaceContext namespaceContext, org.hamcrest.Matcher<java.lang.String> valueMatcher) { return org.hamcrest.xml.HasXPath.hasXPath(xPath, namespaceContext, valueMatcher); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code> within the specified namespace context, with any content. * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes */ public static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext) { return new HasXPath(xPath, namespaceContext, WITH_ANY_CONTENT, XPathConstants.NODE); } }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node contains a node * at the specified <code>xPath</code>, with any content. * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese"))</pre> * * @param xPath * the target xpath */ public static Matcher<Node> hasXPath(String xPath) { return hasXPath(xPath, NO_NAMESPACE_CONTEXT); }
/** * Creates a matcher of {@link org.w3c.dom.Node}s that matches when the examined node has a value at the * specified <code>xPath</code>, within the specified <code>namespaceContext</code>, that satisfies * the specified <code>valueMatcher</code>. * For example: * <pre>assertThat(xml, hasXPath("/root/something[2]/cheese", myNs, equalTo("Cheddar")))</pre> * * @param xPath * the target xpath * @param namespaceContext * the namespace for matching nodes * @param valueMatcher * matcher for the value at the specified xpath */ public static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext, Matcher<String> valueMatcher) { return new HasXPath(xPath, namespaceContext, valueMatcher, STRING); }