I have tests with:
org.springframework.test.web.client.MockRestServiceServer mockServer
When I run with any(String.class)
or exact URL they work well:
mockServer.expect(requestTo(any(String.class)))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Or:
mockServer.expect(requestTo("https://exact-example-url.com/path"))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
I want to expect request by String pattern to avoid checking exact URL. I can write custom matcher like on Spring MockRestServiceServer handling multiple requests to the same URI (auto-discovery)
Is there any other way to make mockServer.expect(requestTo(".*example.*"))
by String pattern?