public interface RequestExpectationManager
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.
Modifier and Type | Method and 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.
|
ClientHttpResponse |
validateRequest(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. |
ResponseActions expectRequest(ExpectedCount count, RequestMatcher requestMatcher)
ResponseActions
is
used to add more expectations and define a response.
This is a delegate for
MockRestServiceServer.expect(ExpectedCount, RequestMatcher)
.
requestMatcher
- a request expectationMockRestServiceServer.expect(RequestMatcher)
,
MockRestServiceServer.expect(ExpectedCount, RequestMatcher)
void verify()
This is a delegate for MockRestServiceServer.verify()
.
AssertionError
- if not all expectations are metMockRestServiceServer.verify()
void verify(Duration timeout)
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.timeout
- how long to wait for all expectations to be metAssertionError
- if not all expectations are met by the specified
timeout, or if any expectation fails at any time before that.void reset()
This is a delegate for MockRestServiceServer.reset()
.
MockRestServiceServer.reset()
ClientHttpResponse validateRequest(ClientHttpRequest request) throws IOException
This is used in MockRestServiceServer
against actual requests.
request
- the requestAssertionError
- when some expectations were not metIOException
- in case of any validation errors