Package org.springframework.test.web.client

# Interface RequestExpectationManager

All Known Implementing Classes:
  `AbstractRequestExpectationManager`, `SimpleRequestExpectationManager`, `UnorderedRequestExpectationManager`

public interface RequestExpectationManager
Encapsulates the behavior required to implement `MockRestServiceServer` including its public API (create expectations + verify/reset) along with an extra method for verifying actual requests.

This contract is not used directly in applications but a custom implementation can be `plugged` in through the `MockRestServiceServer` builder.

Since:
  4.3
Author:
  Rossen Stoyanchev

## Method Summary

Modifier and Type
Method
Description
`ResponseActions`
`expectRequest(ExpectedCount count, RequestMatcher requestMatcher)`
Set up a new request expectation.
`void`
`reset()`
Reset the internal state removing all expectations and recorded requests.
`org.springframework.http.client.ClientHttpResponse`
`validateRequest(org.springframework.http.client.ClientHttpRequest request)`
Validate the given actual request against the declared expectations.
`void`
`verify()`
Verify that all expectations have been met.
`void`
`verify(Duration timeout)`
Variant of `verify()` that waits for up to the specified time for all expectations to be fulfilled.

## Method Details

### expectRequest

ResponseActions expectRequest(ExpectedCount count, RequestMatcher requestMatcher)
Set up a new request expectation. The returned `ResponseActions` is used to add more expectations and define a response.

This is a delegate for `MockRestServiceServer.expect(ExpectedCount, RequestMatcher)`.

Parameters:
  `requestMatcher` - a request expectation
Returns:
  for setting up further expectations and define a response
See Also:
  - `MockRestServiceServer.expect(RequestMatcher)`
  - `MockRestServiceServer.expect(ExpectedCount, RequestMatcher)`

### verify

void verify()
Verify that all expectations have been met.

This is a delegate for `MockRestServiceServer.verify()`.

Throws:
  `AssertionError` - if not all expectations are met
See Also:
  - `MockRestServiceServer.verify()`

### verify

void verify(Duration timeout)
Variant of `verify()` that waits for up to the specified time for all expectations to be fulfilled. This can be useful for tests that involve asynchronous requests.

Parameters:
  `timeout` - how long to wait for all expectations to be met
Throws:
  `AssertionError` - if not all expectations are met by the specified timeout, or if any expectation fails at any time before that.
Since:
  5.3.4

### reset

void reset()
Reset the internal state removing all expectations and recorded requests.

This is a delegate for `MockRestServiceServer.reset()`.

See Also:
  - `MockRestServiceServer.reset()`

### validateRequest

org.springframework.http.client.ClientHttpResponse validateRequest(org.springframework.http.client.ClientHttpRequest request) throws IOException
Validate the given actual request against the declared expectations. Is successful return the mock response to use or raise an error.

This is used in `MockRestServiceServer` against actual requests.

Parameters:
  `request` - the request
Returns:
  the response to return if the request was validated.
Throws:
  `AssertionError` - when some expectations were not met
  `IOException` - in case of any validation errors