Class MockServerRestTemplateCustomizer

java.lang.Object
org.springframework.boot.test.web.client.MockServerRestTemplateCustomizer
All Implemented Interfaces:
RestTemplateCustomizer

public class MockServerRestTemplateCustomizer extends Object implements RestTemplateCustomizer
RestTemplateCustomizer that can be applied to a RestTemplateBuilder instances to add MockRestServiceServer support.

Typically applied to an existing builder before it is used, for example:

 MockServerRestTemplateCustomizer customizer = new MockServerRestTemplateCustomizer();
 MyBean bean = new MyBean(new RestTemplateBuilder(customizer));
 customizer.getServer().expect(requestTo("/hello")).andRespond(withSuccess());
 bean.makeRestCall();
 

If the customizer is only used once, the getServer() method can be used to obtain the mock server. If the customizer has been used more than once the getServer(RestTemplate) or getServers() method must be used to access the related server.

Since:
1.4.0
Author:
Phillip Webb, Moritz Halbritter, Chinmoy Chakraborty
See Also: