org.springframework.test.web.client.match

## Class XpathRequestMatchers

- java.lang.Object
- - org.springframework.test.web.client.match.XpathRequestMatchers

    public class XpathRequestMatchers
    extends Object

Factory methods for request content `RequestMatcher`'s using an XPath expression. An instance of this class is typically accessed via `RequestMatchers.xpath(..)`.

Since:
  3.2
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
`protected` `XpathRequestMatchers(String expression, Map<String,String> namespaces, Object... args)` Class constructor, not for direct instantiation.

### Method Summary

Methods
`<T> RequestMatcher` `booleanValue(Boolean value)` Apply the XPath and assert the boolean value found.
`<T> RequestMatcher` `doesNotExist()` Assert that content does not exist at the given XPath.
`<T> RequestMatcher` `exists()` Assert that content exists at the given XPath.
`<T> RequestMatcher` `node(org.hamcrest.Matcher<? super Node> matcher)` Apply the XPath and assert it with the given `Matcher<Node>`.
`<T> RequestMatcher` `nodeCount(int expectedCount)` Apply the XPath and assert the number of nodes found.
`<T> RequestMatcher` `nodeCount(org.hamcrest.Matcher<Integer> matcher)` Apply the XPath and assert the number of nodes found with the given `Matcher<Integer>`.
`RequestMatcher` `number(Double value)` Apply the XPath and assert the number of nodes found.
`<T> RequestMatcher` `number(org.hamcrest.Matcher<? super Double> matcher)` Apply the XPath and assert the number found with the given matcher.
`<T> RequestMatcher` `string(org.hamcrest.Matcher<? super String> matcher)` Apply the XPath and assert the String content found with the given matcher.
`RequestMatcher` `string(String value)` Apply the XPath and assert the String content found.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### XpathRequestMatchers

    protected XpathRequestMatchers(String expression,
                        Map<String,String> namespaces,
                        Object... args)
                            throws XPathExpressionException

Class constructor, not for direct instantiation. Use `MockRestRequestMatchers.xpath(String, Object...)` or `MockRestRequestMatchers.xpath(String, Map, Object...)`.

Parameters:
  `expression` - the XPath expression
  `namespaces` - 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...)`
Throws:
  `XPathExpressionException`

### Method Detail

#### node

    public <T> RequestMatcher node(org.hamcrest.Matcher<? super Node> matcher)

Apply the XPath and assert it with the given `Matcher<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(org.hamcrest.Matcher<Integer> matcher)

Apply the XPath and assert the number of nodes found with the given `Matcher<Integer>`.

#### nodeCount

    public <T> RequestMatcher nodeCount(int expectedCount)

Apply the XPath and assert the number of nodes found.

#### string

    public <T> RequestMatcher string(org.hamcrest.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(org.hamcrest.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.