public class XpathResultMatchers extends Object
ResultMatcher
's using an XPath
expression. An instance of this class is typically accessed via
MockMvcResultMatchers.xpath(java.lang.String, java.lang.Object...)
.Modifier | Constructor and Description |
---|---|
protected |
XpathResultMatchers(String expression,
Map<String,String> namespaces,
Object... args)
Protected constructor, not for direct instantiation.
|
Modifier and Type | Method and Description |
---|---|
ResultMatcher |
booleanValue(Boolean value)
Evaluate the XPath and assert the
Boolean value found. |
ResultMatcher |
doesNotExist()
Evaluate the XPath and assert that content doesn't exist.
|
ResultMatcher |
exists()
Evaluate the XPath and assert that content exists.
|
ResultMatcher |
node(org.hamcrest.Matcher<? super Node> matcher)
Evaluate the XPath and assert the
Node content found with the
given Hamcrest Matcher . |
ResultMatcher |
nodeCount(int expectedCount)
Evaluate the XPath and assert the number of nodes found.
|
ResultMatcher |
nodeCount(org.hamcrest.Matcher<Integer> matcher)
Evaluate the XPath and assert the number of nodes found with the given
Hamcrest
Matcher . |
ResultMatcher |
number(Double expectedValue)
Evaluate the XPath and assert the
Double value found. |
ResultMatcher |
number(org.hamcrest.Matcher<? super Double> matcher)
Evaluate the XPath and assert the
Double value found with the
given Hamcrest Matcher . |
ResultMatcher |
string(org.hamcrest.Matcher<? super String> matcher)
Apply the XPath and assert the
String value found with the given
Hamcrest Matcher . |
ResultMatcher |
string(String expectedValue)
Apply the XPath and assert the
String value found. |
protected XpathResultMatchers(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
MockMvcResultMatchers.xpath(String, Object...)
or
MockMvcResultMatchers.xpath(String, Map, Object...)
.expression
- the XPath expressionnamespaces
- XML namespaces referenced in the XPath expression, or null
args
- arguments to parameterize the XPath expression with using the
formatting specifiers defined in String.format(String, Object...)
XPathExpressionException
public ResultMatcher node(org.hamcrest.Matcher<? super Node> matcher)
Node
content found with the
given Hamcrest Matcher
.public ResultMatcher exists()
public ResultMatcher doesNotExist()
public ResultMatcher nodeCount(org.hamcrest.Matcher<Integer> matcher)
Matcher
.public ResultMatcher nodeCount(int expectedCount)
public ResultMatcher string(org.hamcrest.Matcher<? super String> matcher)
String
value found with the given
Hamcrest Matcher
.public ResultMatcher string(String expectedValue)
String
value found.public ResultMatcher number(org.hamcrest.Matcher<? super Double> matcher)
Double
value found with the
given Hamcrest Matcher
.public ResultMatcher number(Double expectedValue)
Double
value found.public ResultMatcher booleanValue(Boolean value)
Boolean
value found.