It should be possible to have together RestTemplate and RestClient in application and test them independently.
Unfortunately, currently if RestTemplate is used, RestClient cannot be tested:
org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerAutoConfiguration.DeferredRequestExpectationManager#getDelegate
if (!restTemplateExpectationManagers.isEmpty()) {
Assert.state(restTemplateExpectationManagers.size() == 1,
"Unable to use auto-configured MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has been bound to more than one RestTemplate");
return restTemplateExpectationManagers.values().iterator().next();
}
Assert.state(restClientExpectationManagers.size() == 1,
"Unable to use auto-configured MockRestServiceServer since "
+ "MockServerRestClientCustomizer has been bound to more than one RestClient");
return restClientExpectationManagers.values().iterator().next();