@ -102,6 +102,7 @@ import org.springframework.validation.Validator;
import org.springframework.validation.annotation.Validated ;
import org.springframework.validation.annotation.Validated ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThat ;
import static org.assertj.core.api.Assertions.assertThatException ;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType ;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType ;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException ;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException ;
import static org.assertj.core.api.Assertions.entry ;
import static org.assertj.core.api.Assertions.entry ;
@ -722,11 +723,10 @@ class ConfigurationPropertiesTests {
@Test
@Test
void loadWhenHasConfigurationPropertiesValidatorShouldApplyValidator ( ) {
void loadWhenHasConfigurationPropertiesValidatorShouldApplyValidator ( ) {
assertThatExceptionOfType ( Exception . class ) . isThrownBy ( ( ) - > load ( WithCustomValidatorConfiguration . class ) )
assertThatException ( ) . isThrownBy ( ( ) - > load ( WithCustomValidatorConfiguration . class ) ) . satisfies ( ( ex ) - > {
. satisfies ( ( ex ) - > {
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
} ) ;
} ) ;
}
}
@Test
@Test
@ -739,7 +739,7 @@ class ConfigurationPropertiesTests {
@Test
@Test
void loadWhenConfigurationPropertiesIsAlsoValidatorShouldApplyValidator ( ) {
void loadWhenConfigurationPropertiesIsAlsoValidatorShouldApplyValidator ( ) {
assertThatExceptionOfType ( Exception . class ) . isThrownBy ( ( ) - > load ( ValidatorProperties . class ) ) . satisfies ( ( ex ) - > {
assertThatException ( ) . isThrownBy ( ( ) - > load ( ValidatorProperties . class ) ) . satisfies ( ( ex ) - > {
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
} ) ;
} ) ;
@ -747,8 +747,7 @@ class ConfigurationPropertiesTests {
@Test
@Test
void loadWhenConstructorBoundConfigurationPropertiesIsAlsoValidatorShouldApplyValidator ( ) {
void loadWhenConstructorBoundConfigurationPropertiesIsAlsoValidatorShouldApplyValidator ( ) {
assertThatExceptionOfType ( Exception . class )
assertThatException ( ) . isThrownBy ( ( ) - > load ( ValidatorConstructorBoundPropertiesConfiguration . class ) )
. isThrownBy ( ( ) - > load ( ValidatorConstructorBoundPropertiesConfiguration . class ) )
. satisfies ( ( ex ) - > {
. satisfies ( ( ex ) - > {
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
@ -922,8 +921,7 @@ class ConfigurationPropertiesTests {
Map < String , Object > source = new HashMap < > ( ) ;
Map < String , Object > source = new HashMap < > ( ) ;
source . put ( "test.duration" , "P12D" ) ;
source . put ( "test.duration" , "P12D" ) ;
sources . addLast ( new MapPropertySource ( "test" , source ) ) ;
sources . addLast ( new MapPropertySource ( "test" , source ) ) ;
assertThatExceptionOfType ( Exception . class )
assertThatException ( ) . isThrownBy ( ( ) - > load ( ConstructorParameterWithFormatConfiguration . class ) )
. isThrownBy ( ( ) - > load ( ConstructorParameterWithFormatConfiguration . class ) )
. havingCause ( )
. havingCause ( )
. isInstanceOf ( BindException . class ) ;
. isInstanceOf ( BindException . class ) ;
}
}
@ -934,8 +932,7 @@ class ConfigurationPropertiesTests {
Map < String , Object > source = new HashMap < > ( ) ;
Map < String , Object > source = new HashMap < > ( ) ;
source . put ( "test.period" , "P12D" ) ;
source . put ( "test.period" , "P12D" ) ;
sources . addLast ( new MapPropertySource ( "test" , source ) ) ;
sources . addLast ( new MapPropertySource ( "test" , source ) ) ;
assertThatExceptionOfType ( Exception . class )
assertThatException ( ) . isThrownBy ( ( ) - > load ( ConstructorParameterWithFormatConfiguration . class ) )
. isThrownBy ( ( ) - > load ( ConstructorParameterWithFormatConfiguration . class ) )
. havingCause ( )
. havingCause ( )
. isInstanceOf ( BindException . class ) ;
. isInstanceOf ( BindException . class ) ;
}
}
@ -951,8 +948,7 @@ class ConfigurationPropertiesTests {
@Test
@Test
void loadWhenBindingToConstructorParametersShouldValidate ( ) {
void loadWhenBindingToConstructorParametersShouldValidate ( ) {
assertThatExceptionOfType ( Exception . class )
assertThatException ( ) . isThrownBy ( ( ) - > load ( ConstructorParameterValidationConfiguration . class ) )
. isThrownBy ( ( ) - > load ( ConstructorParameterValidationConfiguration . class ) )
. satisfies ( ( ex ) - > {
. satisfies ( ( ex ) - > {
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex ) . hasCauseInstanceOf ( BindException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;
assertThat ( ex . getCause ( ) ) . hasCauseExactlyInstanceOf ( BindValidationException . class ) ;