diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java index 7e361c87471b..5c489126cb4f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBeanTests.java @@ -197,6 +197,7 @@ void getWhenHasFactoryMethodAndBeanAnnotationFavorsFactoryMethod() throws Throwa void getWhenHasValidatedBeanBindsWithBeanAnnotation() throws Throwable { get(ValidatedBeanConfiguration.class, "validatedBean", (propertiesBean) -> { Validated validated = propertiesBean.asBindTarget().getAnnotation(Validated.class); + assertThat(validated).isNotNull(); assertThat(validated.value()).containsExactly(BeanGroup.class); }); } @@ -205,6 +206,7 @@ void getWhenHasValidatedBeanBindsWithBeanAnnotation() throws Throwable { void getWhenHasValidatedFactoryMethodBindsWithFactoryMethodAnnotation() throws Throwable { get(ValidatedMethodConfiguration.class, "annotatedBean", (propertiesBean) -> { Validated validated = propertiesBean.asBindTarget().getAnnotation(Validated.class); + assertThat(validated).isNotNull(); assertThat(validated.value()).containsExactly(FactoryMethodGroup.class); }); } @@ -213,6 +215,7 @@ void getWhenHasValidatedFactoryMethodBindsWithFactoryMethodAnnotation() throws T void getWhenHasValidatedBeanAndFactoryMethodBindsWithFactoryMethodAnnotation() throws Throwable { get(ValidatedMethodAndBeanConfiguration.class, "validatedBean", (propertiesBean) -> { Validated validated = propertiesBean.asBindTarget().getAnnotation(Validated.class); + assertThat(validated).isNotNull(); assertThat(validated.value()).containsExactly(FactoryMethodGroup.class); }); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindExceptionTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindExceptionTests.java index a658b56a1675..db35d3f8ff51 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindExceptionTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindExceptionTests.java @@ -36,6 +36,7 @@ void createFromBeanHasDetails() { ApplicationContext applicationContext = new AnnotationConfigApplicationContext(Example.class); ConfigurationPropertiesBean bean = ConfigurationPropertiesBean.get(applicationContext, applicationContext.getBean(Example.class), "example"); + assertThat(bean).isNotNull(); ConfigurationPropertiesBindException exception = new ConfigurationPropertiesBindException(bean, new IllegalStateException()); assertThat(exception.getMessage()).isEqualTo("Error creating bean with name 'example': " diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java index 54840252c46b..b8949c416f64 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java @@ -1197,6 +1197,7 @@ void loadWhenBoundToRandomPropertyPlaceholder() { void boundPropertiesShouldBeRecorded() { load(NestedConfiguration.class, "name=foo", "nested.name=bar"); BoundConfigurationProperties bound = BoundConfigurationProperties.get(this.context); + assertThat(bound).isNotNull(); Set keys = bound.getAll().keySet(); assertThat(keys.stream().map(ConfigurationPropertyName::toString)).contains("name", "nested.name"); } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java index b706cadcc979..3c8d07ee326a 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/PropertyMapperTests.java @@ -18,11 +18,11 @@ import java.util.function.Supplier; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.assertj.core.api.Assertions.fail; /** * Tests for {@link PropertyMapper}. @@ -57,7 +57,7 @@ void fromValueAsIntShouldAdaptValue() { @Test void fromValueAlwaysApplyingWhenNonNullShouldAlwaysApplyNonNullToSource() { - this.map.alwaysApplyingWhenNonNull().from((String) null).toCall(() -> fail()); + this.map.alwaysApplyingWhenNonNull().from((String) null).toCall(Assertions::fail); } @Test @@ -101,14 +101,14 @@ void asShouldAdaptSupplier() { @Test void whenNonNullWhenSuppliedNullShouldNotMap() { - this.map.from(() -> null).whenNonNull().as(String::valueOf).toCall(() -> fail()); + this.map.from(() -> null).whenNonNull().as(String::valueOf).toCall(Assertions::fail); } @Test void whenNonNullWhenSuppliedThrowsNullPointerExceptionShouldNotMap() { this.map.from(() -> { throw new NullPointerException(); - }).whenNonNull().as(String::valueOf).toCall(() -> fail()); + }).whenNonNull().as(String::valueOf).toCall(Assertions::fail); } @Test @@ -119,7 +119,7 @@ void whenTrueWhenValueIsTrueShouldMap() { @Test void whenTrueWhenValueIsFalseShouldNotMap() { - this.map.from(false).whenTrue().toCall(() -> fail()); + this.map.from(false).whenTrue().toCall(Assertions::fail); } @Test @@ -130,17 +130,17 @@ void whenFalseWhenValueIsFalseShouldMap() { @Test void whenFalseWhenValueIsTrueShouldNotMap() { - this.map.from(true).whenFalse().toCall(() -> fail()); + this.map.from(true).whenFalse().toCall(Assertions::fail); } @Test void whenHasTextWhenValueIsNullShouldNotMap() { - this.map.from(() -> null).whenHasText().toCall(() -> fail()); + this.map.from(() -> null).whenHasText().toCall(Assertions::fail); } @Test void whenHasTextWhenValueIsEmptyShouldNotMap() { - this.map.from("").whenHasText().toCall(() -> fail()); + this.map.from("").whenHasText().toCall(Assertions::fail); } @Test @@ -157,7 +157,7 @@ void whenEqualToWhenValueIsEqualShouldMatch() { @Test void whenEqualToWhenValueIsNotEqualShouldNotMatch() { - this.map.from("123").whenEqualTo("321").toCall(() -> fail()); + this.map.from("123").whenEqualTo("321").toCall(Assertions::fail); } @Test @@ -169,7 +169,7 @@ void whenInstanceOfWhenValueIsTargetTypeShouldMatch() { @Test void whenInstanceOfWhenValueIsNotTargetTypeShouldNotMatch() { Supplier supplier = () -> 123L; - this.map.from(supplier).whenInstanceOf(Double.class).toCall(() -> fail()); + this.map.from(supplier).whenInstanceOf(Double.class).toCall(Assertions::fail); } @Test @@ -180,7 +180,7 @@ void whenWhenValueMatchesShouldMap() { @Test void whenWhenValueDoesNotMatchShouldNotMap() { - this.map.from("123").when("321"::equals).toCall(() -> fail()); + this.map.from("123").when("321"::equals).toCall(Assertions::fail); } @Test @@ -198,12 +198,12 @@ void whenWhenCombinedWithAsUsesSourceValue() { @Test void alwaysApplyingWhenNonNullShouldAlwaysApplyNonNullToSource() { - this.map.alwaysApplyingWhenNonNull().from(() -> null).toCall(() -> fail()); + this.map.alwaysApplyingWhenNonNull().from(() -> null).toCall(Assertions::fail); } @Test void whenWhenValueNotMatchesShouldSupportChainedCalls() { - this.map.from("123").when("456"::equals).when("123"::equals).toCall(() -> fail()); + this.map.from("123").when("456"::equals).when("123"::equals).toCall(Assertions::fail); } @Test