public class DefaultRequestExpectation extends Object implements RequestExpectation
RequestExpectation
that simply delegates
to the request matchers and the response creator it contains.Modifier and Type | Class and Description |
---|---|
protected static class |
DefaultRequestExpectation.RequestCount
Helper class that keeps track of actual vs expected request count.
|
Constructor and Description |
---|
DefaultRequestExpectation(ExpectedCount expectedCount,
RequestMatcher requestMatcher)
Create a new request expectation that should be called a number of times
as indicated by
RequestCount . |
Modifier and Type | Method and Description |
---|---|
ResponseActions |
andExpect(RequestMatcher requestMatcher)
Add a request expectation.
|
void |
andRespond(ResponseCreator responseCreator)
Define the response.
|
ClientHttpResponse |
createResponse(ClientHttpRequest request)
Create a response for the given request.
|
protected DefaultRequestExpectation.RequestCount |
getRequestCount() |
protected List<RequestMatcher> |
getRequestMatchers() |
protected ResponseCreator |
getResponseCreator() |
boolean |
hasRemainingCount()
Whether there is a remaining count of invocations for this expectation.
|
boolean |
isSatisfied()
Whether the requirements for this request expectation have been met.
|
void |
match(ClientHttpRequest request)
Match the given request against specific expectations.
|
public DefaultRequestExpectation(ExpectedCount expectedCount, RequestMatcher requestMatcher)
RequestCount
.expectedCount
- the expected request expectedCountprotected DefaultRequestExpectation.RequestCount getRequestCount()
protected List<RequestMatcher> getRequestMatchers()
protected ResponseCreator getResponseCreator()
public ResponseActions andExpect(RequestMatcher requestMatcher)
ResponseActions
andExpect
in interface ResponseActions
public void andRespond(ResponseCreator responseCreator)
ResponseActions
andRespond
in interface ResponseActions
responseCreator
- the creator of the responsepublic void match(ClientHttpRequest request) throws IOException
RequestMatcher
match
in interface RequestMatcher
request
- the request to make assertions onIOException
- in case of I/O errorspublic ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException
ResponseCreator
createResponse
in interface ResponseCreator
request
- the requestIOException
public boolean hasRemainingCount()
RequestExpectation
hasRemainingCount
in interface RequestExpectation
public boolean isSatisfied()
RequestExpectation
isSatisfied
in interface RequestExpectation