|
|
@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.validation;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
|
|
import jakarta.validation.ConstraintViolationException;
|
|
|
|
import jakarta.validation.ConstraintViolationException;
|
|
|
|
import jakarta.validation.Validator;
|
|
|
|
import jakarta.validation.Validator;
|
|
|
@ -207,6 +208,7 @@ class ValidationAutoConfigurationTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
void userDefinedMethodValidationPostProcessorTakesPrecedence() {
|
|
|
|
void userDefinedMethodValidationPostProcessorTakesPrecedence() {
|
|
|
|
this.contextRunner.withUserConfiguration(SampleConfiguration.class).run((context) -> {
|
|
|
|
this.contextRunner.withUserConfiguration(SampleConfiguration.class).run((context) -> {
|
|
|
|
assertThat(context.getBeansOfType(Validator.class)).hasSize(1);
|
|
|
|
assertThat(context.getBeansOfType(Validator.class)).hasSize(1);
|
|
|
@ -214,8 +216,9 @@ class ValidationAutoConfigurationTests {
|
|
|
|
assertThat(context.getBean(MethodValidationPostProcessor.class))
|
|
|
|
assertThat(context.getBean(MethodValidationPostProcessor.class))
|
|
|
|
.isSameAs(userMethodValidationPostProcessor);
|
|
|
|
.isSameAs(userMethodValidationPostProcessor);
|
|
|
|
assertThat(context.getBeansOfType(MethodValidationPostProcessor.class)).hasSize(1);
|
|
|
|
assertThat(context.getBeansOfType(MethodValidationPostProcessor.class)).hasSize(1);
|
|
|
|
assertThat(context.getBean(Validator.class))
|
|
|
|
Object validator = ReflectionTestUtils.getField(userMethodValidationPostProcessor, "validator");
|
|
|
|
.isNotSameAs(ReflectionTestUtils.getField(userMethodValidationPostProcessor, "validator"));
|
|
|
|
assertThat(validator).isNotNull().isInstanceOf(Supplier.class);
|
|
|
|
|
|
|
|
assertThat(context.getBean(Validator.class)).isNotSameAs(((Supplier<Validator>) validator).get());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|