diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfiguration.java index 65775e1c587e..769c5a3cc8a9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfiguration.java @@ -34,7 +34,7 @@ public class ApplicationAvailabilityAutoConfiguration { @Bean - @ConditionalOnMissingBean(ApplicationAvailability.class) + @ConditionalOnMissingBean public ApplicationAvailability applicationAvailability() { return new ApplicationAvailabilityBean(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfigurationTests.java index a7adad0e18e1..225ce98f5eb4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/availability/ApplicationAvailabilityAutoConfigurationTests.java @@ -20,13 +20,10 @@ import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.availability.ApplicationAvailability; -import org.springframework.boot.availability.AvailabilityChangeEvent; -import org.springframework.boot.availability.AvailabilityState; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; /** * Tests for {@link ApplicationAvailabilityAutoConfiguration} @@ -46,35 +43,12 @@ void providerIsPresentWhenNotRegistered() { } @Test - void providerIsPresentWithRegisteredOne() { - this.contextRunner.withUserConfiguration(ApplicationAvailabilityConfig.class) + void providerIsNotConfiguredWhenCustomOneIsPresent() { + this.contextRunner + .withBean("customApplicationAvailability", ApplicationAvailability.class, + () -> mock(ApplicationAvailability.class)) .run(((context) -> assertThat(context).hasSingleBean(ApplicationAvailability.class) .hasBean("customApplicationAvailability"))); } - @Configuration(proxyBeanMethods = false) - static class ApplicationAvailabilityConfig { - - @Bean - ApplicationAvailability customApplicationAvailability() { - return new ApplicationAvailability() { - @Override - public S getState(Class stateType, S defaultState) { - return null; - } - - @Override - public S getState(Class stateType) { - return null; - } - - @Override - public AvailabilityChangeEvent getLastChangeEvent(Class stateType) { - return null; - } - }; - } - - } - }