Class DefaultRequestExpectation
java.lang.Object
org.springframework.test.web.client.DefaultRequestExpectation
- All Implemented Interfaces:
- RequestExpectation, RequestMatcher, ResponseActions, ResponseCreator
Default implementation of 
RequestExpectation that simply delegates
to the request matchers and the response creator it contains.- Since:
- 4.3
- Author:
- Rossen Stoyanchev
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classHelper class that keeps track of actual vs expected request count.
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultRequestExpectation(ExpectedCount expectedCount, RequestMatcher requestMatcher) Create a new request expectation that should be called a number of times as indicated byRequestCount.
- 
Method SummaryModifier and TypeMethodDescriptionandExpect(RequestMatcher requestMatcher) Add a request expectation.voidandRespond(ResponseCreator responseCreator) Define the response.createResponse(@Nullable ClientHttpRequest request) Note that as of 5.0.3, the creation of the response, which may block intentionally, is separated from request count tracking, and this method no longer increments the count transparently.protected DefaultRequestExpectation.RequestCountprotected List<RequestMatcher> protected @Nullable ResponseCreatorbooleanWhether there is a remaining count of invocations for this expectation.voidIncrease the matched request count and check we haven't passed the max count.booleanWhether the requirements for this request expectation have been met.voidmatch(ClientHttpRequest request) Match the given request against specific expectations.
- 
Constructor Details- 
DefaultRequestExpectationCreate a new request expectation that should be called a number of times as indicated byRequestCount.- Parameters:
- expectedCount- the expected request expectedCount
 
 
- 
- 
Method Details- 
getRequestCount
- 
getRequestMatchers
- 
getResponseCreator
- 
andExpectDescription copied from interface:ResponseActionsAdd a request expectation.- Specified by:
- andExpectin interface- ResponseActions
- Returns:
- the expectation
 
- 
andRespondDescription copied from interface:ResponseActionsDefine the response.- Specified by:
- andRespondin interface- ResponseActions
- Parameters:
- responseCreator- the creator of the response
 
- 
matchDescription copied from interface:RequestMatcherMatch the given request against specific expectations.- Specified by:
- matchin interface- RequestMatcher
- Parameters:
- request- the request to make assertions on
- Throws:
- IOException- in case of I/O errors
 
- 
createResponseNote that as of 5.0.3, the creation of the response, which may block intentionally, is separated from request count tracking, and this method no longer increments the count transparently. InsteadincrementAndValidate()must be invoked independently.- Specified by:
- createResponsein interface- ResponseCreator
- Parameters:
- request- the request
- Throws:
- IOException
 
- 
hasRemainingCountpublic boolean hasRemainingCount()Description copied from interface:RequestExpectationWhether there is a remaining count of invocations for this expectation.- Specified by:
- hasRemainingCountin interface- RequestExpectation
 
- 
incrementAndValidatepublic void incrementAndValidate()Description copied from interface:RequestExpectationIncrease the matched request count and check we haven't passed the max count.- Specified by:
- incrementAndValidatein interface- RequestExpectation
 
- 
isSatisfiedpublic boolean isSatisfied()Description copied from interface:RequestExpectationWhether the requirements for this request expectation have been met.- Specified by:
- isSatisfiedin interface- RequestExpectation
 
 
-