Class XpathRequestMatchers
- java.lang.Object
- org.springframework.test.web.client.match.XpathRequestMatchers
public class XpathRequestMatchers extends Object
Factory methods for request contentRequestMatcher's using an XPath expression. An instance of this class is typically accessed viaRequestMatchers.xpath(..).- Since:
- 3.2
- Author:
- Rossen Stoyanchev
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> RequestMatcherbooleanValue(Boolean value)Apply the XPath and assert the boolean value found.<T> RequestMatcherdoesNotExist()Assert that content does not exist at the given XPath.<T> RequestMatcherexists()Assert that content exists at the given XPath.<T> RequestMatchernode(Matcher<? super Node> matcher)Apply the XPath and assert it with the givenMatcher<Node>.<T> RequestMatchernodeCount(int expectedCount)Apply the XPath and assert the number of nodes found.<T> RequestMatchernodeCount(Matcher<Integer> matcher)Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>.RequestMatchernumber(Double value)Apply the XPath and assert the number of nodes found.<T> RequestMatchernumber(Matcher<? super Double> matcher)Apply the XPath and assert the number found with the given matcher.RequestMatcherstring(String value)Apply the XPath and assert the String content found.<T> RequestMatcherstring(Matcher<? super String> matcher)Apply the XPath and assert the String content found with the given matcher.
Constructor Detail
XpathRequestMatchers
protected XpathRequestMatchers(String expression, Map<String,String> namespaces, Object... args) throws XPathExpressionException
Class constructor, not for direct instantiation. UseMockRestRequestMatchers.xpath(String, Object...)orMockRestRequestMatchers.xpath(String, Map, Object...).- Parameters:
expression- the XPath expressionnamespaces- XML namespaces referenced in the XPath expression, ornullargs- arguments to parameterize the XPath expression with using the formatting specifiers defined inString.format(String, Object...)- Throws:
XPathExpressionException- if expression compilation failed
Method Detail
node
public <T> RequestMatcher node(Matcher<? super Node> matcher)
Apply the XPath and assert it with the givenMatcher<Node>.
exists
public <T> RequestMatcher exists()
Assert that content exists at the given XPath.
doesNotExist
public <T> RequestMatcher doesNotExist()
Assert that content does not exist at the given XPath.
nodeCount
public <T> RequestMatcher nodeCount(Matcher<Integer> matcher)
Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>.
nodeCount
public <T> RequestMatcher nodeCount(int expectedCount)
Apply the XPath and assert the number of nodes found.
string
public <T> RequestMatcher string(Matcher<? super String> matcher)
Apply the XPath and assert the String content found with the given matcher.
string
public RequestMatcher string(String value)
Apply the XPath and assert the String content found.
number
public <T> RequestMatcher number(Matcher<? super Double> matcher)
Apply the XPath and assert the number found with the given matcher.
number
public RequestMatcher number(Double value)
Apply the XPath and assert the number of nodes found.
booleanValue
public <T> RequestMatcher booleanValue(Boolean value)
Apply the XPath and assert the boolean value found.