接口 RequestExpectationManager
- 所有已知实现类:
AbstractRequestExpectationManager,RootUriRequestExpectationManager,SimpleRequestExpectationManager,UnorderedRequestExpectationManager
public interface RequestExpectationManager
Encapsulates the behavior required to implement
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.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
-
方法概要
修饰符和类型方法说明expectRequest(ExpectedCount count, RequestMatcher requestMatcher) Set up a new request expectation.voidreset()Reset the internal state removing all expectations and recorded requests.cn.taketoday.http.client.ClientHttpResponsevalidateRequest(cn.taketoday.http.client.ClientHttpRequest request) Validate the given actual request against the declared expectations.voidverify()Verify that all expectations have been met.voidVariant ofverify()that waits for up to the specified time for all expectations to be fulfilled.
-
方法详细资料
-
expectRequest
Set up a new request expectation. The returnedResponseActionsis used to add more expectations and define a response.This is a delegate for
MockRestServiceServer.expect(ExpectedCount, RequestMatcher).- 参数:
requestMatcher- a request expectation- 返回:
- for setting up further expectations and define a response
- 另请参阅:
-
verify
void verify()Verify that all expectations have been met.This is a delegate for
MockRestServiceServer.verify().- 抛出:
AssertionError- if not all expectations are met- 另请参阅:
-
verify
Variant ofverify()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 expecations to be met- 抛出:
AssertionError- if not all expectations are met by the specified timeout, or if any expectation fails at any time before that.- 从以下版本开始:
- 4.0
-
reset
void reset()Reset the internal state removing all expectations and recorded requests.This is a delegate for
MockRestServiceServer.reset(). -
validateRequest
cn.taketoday.http.client.ClientHttpResponse validateRequest(cn.taketoday.http.client.ClientHttpRequest request) throws IOException Validate the given actual request against the declared expectations. Is successful return the mock response to use or raise an error.This is used in
MockRestServiceServeragainst actual requests.- 参数:
request- the request- 返回:
- the response to return if the request was validated.
- 抛出:
AssertionError- when some expectations were not metIOException- in case of any validation errors
-