Uses of Interface
org.springframework.test.web.client.RequestMatcher
Package
Description
Contains client-side REST testing support.
Contains built-in
RequestMatcher
implementations.-
Uses of RequestMatcher in org.springframework.test.web.client
Modifier and TypeInterfaceDescriptioninterface
An extension ofResponseActions
that also implementsRequestMatcher
andResponseCreator
Modifier and TypeClassDescriptionclass
Default implementation ofRequestExpectation
that simply delegates to the request matchers and the response creator it contains.Modifier and TypeMethodDescriptionprotected List<RequestMatcher>
DefaultRequestExpectation.getRequestMatchers()
Modifier and TypeMethodDescriptionDefaultRequestExpectation.andExpect
(RequestMatcher requestMatcher) ResponseActions.andExpect
(RequestMatcher requestMatcher) Add a request expectation.MockRestServiceServer.expect
(ExpectedCount count, RequestMatcher matcher) An alternative toMockRestServiceServer.expect(RequestMatcher)
that also indicates how many times the request is expected to be executed.MockRestServiceServer.expect
(RequestMatcher matcher) Set up an expectation for a single HTTP request.AbstractRequestExpectationManager.expectRequest
(ExpectedCount count, RequestMatcher matcher) RequestExpectationManager.expectRequest
(ExpectedCount count, RequestMatcher requestMatcher) Set up a new request expectation.ModifierConstructorDescriptionDefaultRequestExpectation
(ExpectedCount expectedCount, RequestMatcher requestMatcher) Create a new request expectation that should be called a number of times as indicated byRequestCount
. -
Uses of RequestMatcher in org.springframework.test.web.client.match
Modifier and TypeMethodDescriptionstatic RequestMatcher
MockRestRequestMatchers.anything()
Match to any request.XpathRequestMatchers.booleanValue
(Boolean value) Apply the XPath and assert the boolean value found.ContentRequestMatchers.bytes
(byte[] expectedContent) Compare the body of the request to the given byte array.ContentRequestMatchers.contentType
(String expectedContentType) Assert the request content type as a String.ContentRequestMatchers.contentType
(MediaType expectedContentType) Assert the request content type as aMediaType
.ContentRequestMatchers.contentTypeCompatibleWith
(String contentType) Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType)
.ContentRequestMatchers.contentTypeCompatibleWith
(MediaType contentType) Assert the request content type is compatible with the given content type as defined byMediaType.isCompatibleWith(MediaType)
.JsonPathRequestMatchers.doesNotExist()
Evaluate the JSON path expression against the request content and assert that a value does not exist at the given path.XpathRequestMatchers.doesNotExist()
Assert that content does not exist at the given XPath.JsonPathRequestMatchers.doesNotHaveJsonPath()
Evaluate the JSON path expression against the suppliedcontent
and assert that a value, includingnull
values, does not exist at the given path.JsonPathRequestMatchers.exists()
Evaluate the JSON path expression against the request content and assert that a non-null value exists at the given path.XpathRequestMatchers.exists()
Assert that content exists at the given XPath.ContentRequestMatchers.formData
(MultiValueMap<String, String> expected) Parse the body as form data and compare to the givenMultiValueMap
.ContentRequestMatchers.formDataContains
(Map<String, String> expected) Variant ofContentRequestMatchers.formData(MultiValueMap)
that matches the given subset of expected form parameters.JsonPathRequestMatchers.hasJsonPath()
Evaluate the JSON path expression against the response content and assert that a value, possiblynull
, exists.static RequestMatcher
Assert request header values.static RequestMatcher
Assert request header values with the given Hamcrest matcher(s).static RequestMatcher
MockRestRequestMatchers.headerDoesNotExist
(String name) Assert that the given request header does not exist.static RequestMatcher
MockRestRequestMatchers.headerList
(String name, Matcher<? super List<String>> matcher) Assert request header values with the given Hamcrest matcher, matching on the entireList
of values.JsonPathRequestMatchers.isArray()
Evaluate the JSON path expression against the request content and assert that the result is an array.JsonPathRequestMatchers.isBoolean()
Evaluate the JSON path expression against the request content and assert that the result is aBoolean
.JsonPathRequestMatchers.isEmpty()
Evaluate the JSON path expression against the request content and assert that an empty value exists at the given path.JsonPathRequestMatchers.isMap()
Evaluate the JSON path expression against the request content and assert that the result is aMap
.JsonPathRequestMatchers.isNotEmpty()
Evaluate the JSON path expression against the request content and assert that a non-empty value exists at the given path.JsonPathRequestMatchers.isNumber()
Evaluate the JSON path expression against the request content and assert that the result is aNumber
.JsonPathRequestMatchers.isString()
Evaluate the JSON path expression against the request content and assert that the result is aString
.Parse the expected and actual strings as JSON and assert the two are "similar" - i.e.Deprecated.ContentRequestMatchers.json
(String expectedJsonContent, JsonComparator comparator) Parse the request body and the given string as JSON and assert the two using the givenJsonComparator
.ContentRequestMatchers.json
(String expectedJsonContent, JsonCompareMode compareMode) Parse the request body and the given string as JSON and assert the two using the given mode.static <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.static RequestMatcher
MockRestRequestMatchers.method
(HttpMethod method) Assert theHttpMethod
of the request.ContentRequestMatchers.multipartData
(MultiValueMap<String, ?> expectedMap) Parse the body as multipart data and assert it contains exactly the values from the givenMultiValueMap
.ContentRequestMatchers.multipartData
(MultiValueMap<String, ?> expectedMap, Charset defaultCharset) Variant ofContentRequestMatchers.multipartData(MultiValueMap)
with a defaultCharset.ContentRequestMatchers.multipartDataContains
(Map<String, ?> expectedMap) Variant ofContentRequestMatchers.multipartData(MultiValueMap)
that does the same but only for a subset of the actual values.Apply the XPath and assert it with the givenMatcher<Node>
.XpathRequestMatchers.nodeCount
(int expectedCount) Apply the XPath and assert the number of nodes found.Apply the XPath and assert the number of nodes found with the givenMatcher<Integer>
.Apply the XPath and assert the number value found.Apply the XPath and assert the number found with the given matcher.static RequestMatcher
MockRestRequestMatchers.queryParam
(String name, String... expectedValues) Assert request query parameter values.static RequestMatcher
MockRestRequestMatchers.queryParam
(String name, Matcher<? super String>... matchers) Assert request query parameter values with the given Hamcrest matcher(s).static RequestMatcher
MockRestRequestMatchers.queryParamList
(String name, Matcher<? super List<String>> matcher) Assert request query parameter values with the given Hamcrest matcher, matching on the entireList
of values.static RequestMatcher
Assert the request URI matches the given string.static RequestMatcher
Expect a request to the given URI.static RequestMatcher
Assert the request URI string with the given Hamcrest matcher.static RequestMatcher
MockRestRequestMatchers.requestToUriTemplate
(String expectedUri, Object... uriVars) Variant ofMockRestRequestMatchers.requestTo(URI)
that prepares the URI from a URI template plus optional variables viaUriComponentsBuilder
including encoding.Get the body of the request as a UTF-8 string and compare it to the given String.Get the body of the request as a UTF-8 string and apply the givenMatcher
.Apply the XPath and assert the String content found.Apply the XPath and assert the String content found with the given matcher.Evaluate the JSON path expression against the request content and assert that the result is equal to the supplied value.<T> RequestMatcher
Evaluate the JSON path expression against the request content and assert the resulting value with the given HamcrestMatcher
.<T> RequestMatcher
An overloaded variant ofJsonPathRequestMatchers.value(Matcher)
that also accepts a target type for the resulting value that the matcher can work reliably against.Parse the request body and the given String as XML and assert that the two are "similar" - i.e.
ContentRequestMatchers.json(String, JsonCompareMode)