spring-framework / org.springframework.test.web.client.match / MockRestRequestMatchers

MockRestRequestMatchers

abstract class MockRestRequestMatchers

Static factory methods for RequestMatcher classes. Typically used to provide input for MockRestServiceServer#expect(RequestMatcher). Eclipse Users

Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".

Author
Craig Walls

Author
Rossen Stoyanchev

Since
3.2

Constructors

<init>

MockRestRequestMatchers()

Static factory methods for RequestMatcher classes. Typically used to provide input for MockRestServiceServer#expect(RequestMatcher). Eclipse Users

Consider adding this class as a Java editor favorite. To navigate to this setting, open the Preferences and type "favorites".

Functions

anything

open static fun anything(): RequestMatcher

Match to any request.

content

open static fun content(): ContentRequestMatchers

Access to request body matchers.

header

open static fun header(name: String, vararg matchers: Matcher<in String>): RequestMatcher

Assert request header values with the given Hamcrest matcher.

open static fun header(name: String, vararg expectedValues: String): RequestMatcher

Assert request header values.

jsonPath

open static fun jsonPath(expression: String, vararg args: Any): JsonPathRequestMatchers

Access to request body matchers using a JsonPath expression to inspect a specific subset of the body. The JSON path expression can be a parameterized string using formatting specifiers as defined in String#format(String, Object...).

open static fun <T : Any> jsonPath(expression: String, matcher: Matcher<T>): RequestMatcher

Access to request body matchers using a JsonPath expression to inspect a specific subset of the body and a Hamcrest match for asserting the value found at the JSON path.

method

open static fun method(method: HttpMethod): RequestMatcher

Assert the HttpMethod of the request.

queryParam

open static fun queryParam(name: String, vararg matchers: Matcher<in String>): RequestMatcher

Assert request query parameter values with the given Hamcrest matcher.

open static fun queryParam(name: String, vararg expectedValues: String): RequestMatcher

Assert request query parameter values.

requestTo

open static fun requestTo(matcher: Matcher<String>): RequestMatcher

Assert the request URI string with the given matcher.

open static fun requestTo(expectedUri: String): RequestMatcher

Assert the request URI matches the given string.

open static fun requestTo(uri: URI): RequestMatcher

Expect a request to the given URI.

requestToUriTemplate

open static fun requestToUriTemplate(expectedUri: String, vararg uriVars: Any): RequestMatcher

Variant of #requestTo(URI) that prepares the URI from a URI template plus optional variables via UriComponentsBuilder including encoding.

xpath

open static fun xpath(expression: String, vararg args: Any): XpathRequestMatchers

Access to request body matchers using an XPath to inspect a specific subset of the body. The XPath expression can be a parameterized string using formatting specifiers as defined in String#format(String, Object...).

open static fun xpath(expression: String, namespaces: MutableMap<String, String>, vararg args: Any): XpathRequestMatchers

Access to response body matchers using an XPath to inspect a specific subset of the body. The XPath expression can be a parameterized string using formatting specifiers as defined in String#format(String, Object...).