From 3b90919313bd3294c848f4c6c4829a5feb8ffeb8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 6 Jul 2023 12:22:54 +0100 Subject: [PATCH] Polish RestClient auto-config and tests For consistency, replace webClient and WebClient with restClient and RestClient. This also address a bean name clash between RestClientAutoConfiguration's RestClient.Builder bean and WebClientAutoConfiguration's WebClient.Builder bean that were both previously named webClientBuilder. --- .../web/client/RestClientAutoConfiguration.java | 2 +- .../web/client/RestClientAutoConfigurationTests.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java index b33fc882f9..1543caa80d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfiguration.java @@ -59,7 +59,7 @@ public class RestClientAutoConfiguration { @Bean @Scope("prototype") @ConditionalOnMissingBean - public RestClient.Builder webClientBuilder(ObjectProvider customizerProvider) { + public RestClient.Builder restClientBuilder(ObjectProvider customizerProvider) { RestClient.Builder builder = RestClient.builder() .requestFactory(ClientHttpRequestFactories.get(ClientHttpRequestFactorySettings.DEFAULTS)); customizerProvider.orderedStream().forEach((customizer) -> customizer.customize(builder)); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfigurationTests.java index 368c29d88d..b64a62d1f3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/client/RestClientAutoConfigurationTests.java @@ -61,7 +61,7 @@ class RestClientAutoConfigurationTests { void restClientShouldApplyCustomizers() { this.contextRunner.withUserConfiguration(RestClientCustomizerConfig.class).run((context) -> { RestClient.Builder builder = context.getBean(RestClient.Builder.class); - RestClientCustomizer customizer = context.getBean("webClientCustomizer", RestClientCustomizer.class); + RestClientCustomizer customizer = context.getBean("restClientCustomizer", RestClientCustomizer.class); builder.build(); then(customizer).should().customize(any(RestClient.Builder.class)); }); @@ -80,7 +80,7 @@ class RestClientAutoConfigurationTests { void shouldNotCreateClientBuilderIfAlreadyPresent() { this.contextRunner.withUserConfiguration(CustomRestClientBuilderConfig.class).run((context) -> { RestClient.Builder builder = context.getBean(RestClient.Builder.class); - assertThat(builder).isInstanceOf(MyWebClientBuilder.class); + assertThat(builder).isInstanceOf(MyRestClientBuilder.class); }); } @@ -141,7 +141,7 @@ class RestClientAutoConfigurationTests { static class RestClientCustomizerConfig { @Bean - RestClientCustomizer webClientCustomizer() { + RestClientCustomizer restClientCustomizer() { return mock(RestClientCustomizer.class); } @@ -151,13 +151,13 @@ class RestClientAutoConfigurationTests { static class CustomRestClientBuilderConfig { @Bean - MyWebClientBuilder myWebClientBuilder() { - return mock(MyWebClientBuilder.class); + MyRestClientBuilder myRestClientBuilder() { + return mock(MyRestClientBuilder.class); } } - interface MyWebClientBuilder extends RestClient.Builder { + interface MyRestClientBuilder extends RestClient.Builder { }