类 DefaultRequestExpectation
java.lang.Object
cn.taketoday.test.web.client.DefaultRequestExpectation
- 所有已实现的接口:
RequestExpectation,RequestMatcher,ResponseActions,ResponseCreator
Default implementation of
RequestExpectation that simply delegates
to the request matchers and the response creator it contains.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
-
嵌套类概要
嵌套类修饰符和类型类说明protected static classHelper class that keeps track of actual vs expected request count. -
字段概要
字段修饰符和类型字段说明private final DefaultRequestExpectation.RequestCountprivate final List<RequestMatcher>private ResponseCreator -
构造器概要
构造器构造器说明DefaultRequestExpectation(ExpectedCount expectedCount, RequestMatcher requestMatcher) Create a new request expectation that should be called a number of times as indicated byRequestCount. -
方法概要
修饰符和类型方法说明andExpect(RequestMatcher requestMatcher) Add a request expectation.voidandRespond(ResponseCreator responseCreator) Define the response.cn.taketoday.http.client.ClientHttpResponsecreateResponse(cn.taketoday.http.client.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 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(cn.taketoday.http.client.ClientHttpRequest request) Match the given request against specific expectations.
-
字段详细资料
-
requestCount
-
requestMatchers
-
responseCreator
-
-
构造器详细资料
-
DefaultRequestExpectation
Create a new request expectation that should be called a number of times as indicated byRequestCount.- 参数:
expectedCount- the expected request expectedCount
-
-
方法详细资料
-
getRequestCount
-
getRequestMatchers
-
getResponseCreator
-
andExpect
从接口复制的说明:ResponseActionsAdd a request expectation.- 指定者:
andExpect在接口中ResponseActions- 返回:
- the expectation
-
andRespond
从接口复制的说明:ResponseActionsDefine the response.- 指定者:
andRespond在接口中ResponseActions- 参数:
responseCreator- the creator of the response
-
match
从接口复制的说明:RequestMatcherMatch the given request against specific expectations.- 指定者:
match在接口中RequestMatcher- 参数:
request- the request to make assertions on- 抛出:
IOException- in case of I/O errors
-
createResponse
public cn.taketoday.http.client.ClientHttpResponse createResponse(@Nullable cn.taketoday.http.client.ClientHttpRequest request) throws IOException 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. InsteadincrementAndValidate()must be invoked independently.- 指定者:
createResponse在接口中ResponseCreator- 参数:
request- the request- 抛出:
IOException
-
hasRemainingCount
public boolean hasRemainingCount()从接口复制的说明:RequestExpectationWhether there is a remaining count of invocations for this expectation.- 指定者:
hasRemainingCount在接口中RequestExpectation
-
incrementAndValidate
public void incrementAndValidate()从接口复制的说明:RequestExpectationIncrease the matched request count and check we haven't passed the max count.- 指定者:
incrementAndValidate在接口中RequestExpectation
-
isSatisfied
public boolean isSatisfied()从接口复制的说明:RequestExpectationWhether the requirements for this request expectation have been met.- 指定者:
isSatisfied在接口中RequestExpectation
-