use of org.springframework.test.web.client.RequestExpectationManager in project spring-boot by spring-projects.
the class RootUriRequestExpectationManagerTests method forRestTemplateWhenUsingRootUriTemplateHandlerShouldReturnRootUriRequestExpectationManager.
@Test
void forRestTemplateWhenUsingRootUriTemplateHandlerShouldReturnRootUriRequestExpectationManager() {
RestTemplate restTemplate = new RestTemplateBuilder().rootUri(this.uri).build();
RequestExpectationManager actual = RootUriRequestExpectationManager.forRestTemplate(restTemplate, this.delegate);
assertThat(actual).isInstanceOf(RootUriRequestExpectationManager.class);
assertThat(actual).extracting("rootUri").isEqualTo(this.uri);
}
use of org.springframework.test.web.client.RequestExpectationManager in project spring-boot by spring-projects.
the class MockServerRestTemplateCustomizer method customize.
@Override
public void customize(RestTemplate restTemplate) {
RequestExpectationManager expectationManager = createExpectationManager();
if (this.detectRootUri) {
expectationManager = RootUriRequestExpectationManager.forRestTemplate(restTemplate, expectationManager);
}
MockRestServiceServer server = MockRestServiceServer.bindTo(restTemplate).build(expectationManager);
this.expectationManagers.put(restTemplate, expectationManager);
this.servers.put(restTemplate, server);
}
use of org.springframework.test.web.client.RequestExpectationManager in project spring-boot by spring-projects.
the class MockServerRestTemplateCustomizerTests method getExpectationManagersShouldReturnExpectationManagers.
@Test
void getExpectationManagersShouldReturnExpectationManagers() {
RestTemplate template1 = new RestTemplate();
RestTemplate template2 = new RestTemplate();
this.customizer.customize(template1);
this.customizer.customize(template2);
RequestExpectationManager manager1 = this.customizer.getExpectationManagers().get(template1);
RequestExpectationManager manager2 = this.customizer.getExpectationManagers().get(template2);
assertThat(this.customizer.getServer(template1)).extracting("expectationManager").isEqualTo(manager1);
assertThat(this.customizer.getServer(template2)).extracting("expectationManager").isEqualTo(manager2);
}
use of org.springframework.test.web.client.RequestExpectationManager in project spring-boot by spring-projects.
the class RootUriRequestExpectationManagerTests method forRestTemplateWhenNotUsingRootUriTemplateHandlerShouldReturnOriginalRequestExpectationManager.
@Test
void forRestTemplateWhenNotUsingRootUriTemplateHandlerShouldReturnOriginalRequestExpectationManager() {
RestTemplate restTemplate = new RestTemplateBuilder().build();
RequestExpectationManager actual = RootUriRequestExpectationManager.forRestTemplate(restTemplate, this.delegate);
assertThat(actual).isSameAs(this.delegate);
}
Aggregations