RootUriRequestExpectationManager

RequestExpectationManager that strips the specified root URI from the request before verification. Can be used to simply test declarations when all REST calls start the same way. For example:

RestTemplate restTemplate = new RestTemplateBuilder().rootUri("https://example.com").build();
MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
server.expect(requestTo("/hello")).andRespond(withSuccess());
restTemplate.getForEntity("/hello", String.class);

Author

Phillip Webb

Since

1.4.0

See also

Constructors

Link copied to clipboard
constructor(rootUri: String, expectationManager: RequestExpectationManager)

Functions

Link copied to clipboard
open fun bindTo(restTemplate: RestTemplate): MockRestServiceServer
open fun bindTo(restTemplate: RestTemplate, expectationManager: RequestExpectationManager): MockRestServiceServer
Return a bound MockRestServiceServer for the given RestTemplate, configured with RootUriRequestExpectationManager when possible.
Link copied to clipboard
open fun expectRequest(count: ExpectedCount, requestMatcher: RequestMatcher): ResponseActions
Link copied to clipboard
Return RequestExpectationManager to be used for binding with the specified RestTemplate.
Link copied to clipboard
open fun reset()
Link copied to clipboard
Link copied to clipboard
open fun verify()
open fun verify(timeout: Duration)