public abstract class AbstractRequestExpectationManager extends Object implements RequestExpectationManager
RequestExpectationManager
implementations responsible
for storing expectations and actual requests, and checking for unsatisfied
expectations at the end.
Subclasses are responsible for validating each request by matching it to to expectations following the order of declaration or not.
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractRequestExpectationManager.RequestExpectationGroup
Helper class to manage a group of request expectations.
|
Constructor and Description |
---|
AbstractRequestExpectationManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
afterExpectationsDeclared()
Invoked after the phase of declaring expected requests is over.
|
protected AssertionError |
createUnexpectedRequestError(ClientHttpRequest request)
Return an
AssertionError that a sub-class can raise for an
unexpected request. |
ResponseActions |
expectRequest(ExpectedCount count,
RequestMatcher matcher)
Set up a new request expectation.
|
protected List<RequestExpectation> |
getExpectations() |
protected String |
getRequestDetails()
Return details of executed requests.
|
protected List<ClientHttpRequest> |
getRequests() |
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.
|
protected abstract ClientHttpResponse |
validateRequestInternal(ClientHttpRequest request)
Subclasses must implement the actual validation of the request
matching it to a declared expectation.
|
void |
verify()
Verify that all expectations have been met.
|
protected List<RequestExpectation> getExpectations()
protected List<ClientHttpRequest> getRequests()
public ResponseActions expectRequest(ExpectedCount count, RequestMatcher matcher)
RequestExpectationManager
ResponseActions
is
used to add more expectations and define a response.expectRequest
in interface RequestExpectationManager
matcher
- a request expectationpublic ClientHttpResponse validateRequest(ClientHttpRequest request) throws IOException
RequestExpectationManager
validateRequest
in interface RequestExpectationManager
request
- the requestIOException
protected void afterExpectationsDeclared()
validateRequest(org.springframework.http.client.ClientHttpRequest)
on the first actual request.protected abstract ClientHttpResponse validateRequestInternal(ClientHttpRequest request) throws IOException
IOException
public void verify()
RequestExpectationManager
verify
in interface RequestExpectationManager
protected String getRequestDetails()
protected AssertionError createUnexpectedRequestError(ClientHttpRequest request)
AssertionError
that a sub-class can raise for an
unexpected request.public void reset()
RequestExpectationManager
reset
in interface RequestExpectationManager