public class HasXPath extends TypeSafeDiagnosingMatcher<Node>
| Modifier and Type | Field and Description |
|---|---|
static NamespaceContext |
NO_NAMESPACE_CONTEXT |
| Constructor and Description |
|---|
HasXPath(String xPathExpression,
Matcher<String> valueMatcher) |
HasXPath(String xPathExpression,
NamespaceContext namespaceContext,
Matcher<String> valueMatcher) |
| Modifier and Type | Method and Description |
|---|---|
void |
describeTo(Description description)
Generates a description of the object.
|
static Matcher<Node> |
hasXPath(String xPath)
Creates a matcher of
Nodes that matches when the examined node contains a node
at the specified xPath, with any content. |
static Matcher<Node> |
hasXPath(String xPath,
Matcher<String> valueMatcher)
Creates a matcher of
Nodes that matches when the examined node has a value at the
specified xPath that satisfies the specified valueMatcher. |
static Matcher<Node> |
hasXPath(String xPath,
NamespaceContext namespaceContext)
Creates a matcher of
Nodes that matches when the examined node contains a node
at the specified xPath within the specified namespace context, with any content. |
static Matcher<Node> |
hasXPath(String xPath,
NamespaceContext namespaceContext,
Matcher<String> valueMatcher)
Creates a matcher of
Nodes that matches when the examined node has a value at the
specified xPath, within the specified namespaceContext, that satisfies
the specified valueMatcher. |
boolean |
matchesSafely(Node item,
Description mismatch)
Subclasses should implement this.
|
describeMismatch, matches_dont_implement_Matcher___instead_extend_BaseMatcher_, isNotNull, toStringpublic static final NamespaceContext NO_NAMESPACE_CONTEXT
public HasXPath(String xPathExpression, Matcher<String> valueMatcher)
xPathExpression - XPath expression.valueMatcher - Matcher to use at given XPath.
May be null to specify that the XPath must exist but the value is irrelevant.public HasXPath(String xPathExpression, NamespaceContext namespaceContext, Matcher<String> valueMatcher)
xPathExpression - XPath expression.namespaceContext - Resolves XML namespace prefixes in the XPath expressionvalueMatcher - Matcher to use at given XPath.
May be null to specify that the XPath must exist but the value is irrelevant.public boolean matchesSafely(Node item, Description mismatch)
TypeSafeDiagnosingMatchermatchesSafely in class TypeSafeDiagnosingMatcher<Node>public void describeTo(Description description)
SelfDescribingdescription - The description to be built or appended to.public static Matcher<Node> hasXPath(String xPath, Matcher<String> valueMatcher)
Nodes that matches when the examined node has a value at the
specified xPath that satisfies the specified valueMatcher.
For example:
assertThat(xml, hasXPath("/root/something[2]/cheese", equalTo("Cheddar")))xPath - the target xpathvalueMatcher - matcher for the value at the specified xpathpublic static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext, Matcher<String> valueMatcher)
Nodes that matches when the examined node has a value at the
specified xPath, within the specified namespaceContext, that satisfies
the specified valueMatcher.
For example:
assertThat(xml, hasXPath("/root/something[2]/cheese", myNs, equalTo("Cheddar")))xPath - the target xpathnamespaceContext - the namespace for matching nodesvalueMatcher - matcher for the value at the specified xpathpublic static Matcher<Node> hasXPath(String xPath)
Nodes that matches when the examined node contains a node
at the specified xPath, with any content.
For example:
assertThat(xml, hasXPath("/root/something[2]/cheese"))xPath - the target xpathpublic static Matcher<Node> hasXPath(String xPath, NamespaceContext namespaceContext)
Nodes that matches when the examined node contains a node
at the specified xPath within the specified namespace context, with any content.
For example:
assertThat(xml, hasXPath("/root/something[2]/cheese", myNs))xPath - the target xpathnamespaceContext - the namespace for matching nodesCopyright © 2021. All rights reserved.