use of org.springframework.boot.autoconfigure.validation.SpringValidator in project spring-boot by spring-projects.
the class WebFluxAnnotationAutoConfigurationTests method validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303.
@Test
public void validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303() {
load(WebFluxJsr303Validator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).isEmpty();
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
Validator validator = this.context.getBean(Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(WebFluxJsr303Validator.class).validator);
}
use of org.springframework.boot.autoconfigure.validation.SpringValidator in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303.
@Test
public void validationCustomConfigurerTakesPrecedenceAndDoNotExposeJsr303() {
load(MvcJsr303Validator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).isEmpty();
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
Validator validator = this.context.getBean(Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(MvcJsr303Validator.class).validator);
}
use of org.springframework.boot.autoconfigure.validation.SpringValidator in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method validationJsr303CustomValidatorReusedAsSpringValidator.
@Test
public void validationJsr303CustomValidatorReusedAsSpringValidator() {
load(CustomValidator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).hasSize(1);
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(2);
Validator validator = this.context.getBean("mvcValidator", Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(javax.validation.Validator.class));
}
use of org.springframework.boot.autoconfigure.validation.SpringValidator in project spring-boot by spring-projects.
the class WebFluxAnnotationAutoConfigurationTests method validationJsr303CustomValidatorReusedAsSpringValidator.
@Test
public void validationJsr303CustomValidatorReusedAsSpringValidator() {
load(CustomValidator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).hasSize(1);
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(2);
Validator validator = this.context.getBean("webFluxValidator", Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
assertThat(((SpringValidator) validator).getTarget()).isSameAs(this.context.getBean(javax.validation.Validator.class));
}
use of org.springframework.boot.autoconfigure.validation.SpringValidator in project spring-boot by spring-projects.
the class WebFluxAnnotationAutoConfigurationTests method validationJsr303ValidatorExposedAsSpringValidator.
@Test
public void validationJsr303ValidatorExposedAsSpringValidator() {
load(Jsr303Validator.class);
assertThat(this.context.getBeansOfType(ValidatorFactory.class)).isEmpty();
assertThat(this.context.getBeansOfType(javax.validation.Validator.class)).hasSize(1);
assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1);
Validator validator = this.context.getBean(Validator.class);
assertThat(validator).isInstanceOf(SpringValidator.class);
SpringValidatorAdapter target = ((SpringValidator) validator).getTarget();
assertThat(new DirectFieldAccessor(target).getPropertyValue("targetValidator")).isSameAs(this.context.getBean(javax.validation.Validator.class));
}
Aggregations