use of org.springframework.boot.web.client.RestTemplateCustomizer in project spring-boot by spring-projects.
the class RestTemplateAutoConfigurationTests method restTemplateShouldApplyCustomizer.
@Test
public void restTemplateShouldApplyCustomizer() throws Exception {
load(RestTemplateCustomizerConfig.class, RestTemplateConfig.class);
RestTemplate restTemplate = this.context.getBean(RestTemplate.class);
RestTemplateCustomizer customizer = this.context.getBean(RestTemplateCustomizer.class);
verify(customizer).customize(restTemplate);
}
use of org.springframework.boot.web.client.RestTemplateCustomizer in project spring-boot by spring-projects.
the class RestTemplateAutoConfiguration method restTemplateBuilder.
@Bean
@ConditionalOnMissingBean
public RestTemplateBuilder restTemplateBuilder() {
RestTemplateBuilder builder = new RestTemplateBuilder();
HttpMessageConverters converters = this.messageConverters.getIfUnique();
if (converters != null) {
builder = builder.messageConverters(converters.getConverters());
}
List<RestTemplateCustomizer> customizers = this.restTemplateCustomizers.getIfAvailable();
if (!CollectionUtils.isEmpty(customizers)) {
customizers = new ArrayList<>(customizers);
AnnotationAwareOrderComparator.sort(customizers);
builder = builder.customizers(customizers);
}
return builder;
}
Aggregations