Search in sources :

Example 11 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-framework by spring-projects.

the class ModelAttributeMethodArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
    validator.afterPropertiesSet();
    ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer();
    initializer.setValidator(validator);
    this.bindContext = new BindingContext(initializer);
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) BindingContext(org.springframework.web.reactive.BindingContext) Before(org.junit.Before)

Example 12 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-petclinic by spring-projects.

the class ValidatorTests method createValidator.

private Validator createValidator() {
    LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.afterPropertiesSet();
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 13 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-boot by spring-projects.

the class SpringValidatorTests method wrapperInvokesCallbackOnNonManagedBean.

@Test
public void wrapperInvokesCallbackOnNonManagedBean() {
    load(NonManagedBeanConfig.class);
    LocalValidatorFactoryBean validator = this.context.getBean(NonManagedBeanConfig.class).validator;
    verify(validator, times(1)).setApplicationContext(any(ApplicationContext.class));
    verify(validator, times(1)).afterPropertiesSet();
    verify(validator, times(0)).destroy();
    this.context.close();
    this.context = null;
    verify(validator, times(1)).destroy();
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 14 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-boot by spring-projects.

the class SpringValidatorTests method wrapperDoesNotInvokeCallbackOnManagedBean.

@Test
public void wrapperDoesNotInvokeCallbackOnManagedBean() {
    load(ManagedBeanConfig.class);
    LocalValidatorFactoryBean validator = this.context.getBean(ManagedBeanConfig.class).validator;
    verify(validator, times(0)).setApplicationContext(any(ApplicationContext.class));
    verify(validator, times(0)).afterPropertiesSet();
    verify(validator, times(0)).destroy();
    this.context.close();
    this.context = null;
    verify(validator, times(0)).destroy();
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 15 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project spring-boot by spring-projects.

the class RelaxedDataBinderTests method getBinder.

private RelaxedDataBinder getBinder(Object target, String namePrefix) {
    RelaxedDataBinder binder = new RelaxedDataBinder(target, namePrefix);
    binder.setIgnoreUnknownFields(false);
    LocalValidatorFactoryBean validatorFactoryBean = new LocalValidatorFactoryBean();
    validatorFactoryBean.afterPropertiesSet();
    binder.setValidator(validatorFactoryBean);
    binder.setConversionService(this.conversionService);
    return binder;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Aggregations

LocalValidatorFactoryBean (org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)16 Test (org.junit.Test)6 Bean (org.springframework.context.annotation.Bean)4 ConfigurableWebBindingInitializer (org.springframework.web.bind.support.ConfigurableWebBindingInitializer)4 Before (org.junit.Before)3 ApplicationContext (org.springframework.context.ApplicationContext)3 ConversionService (org.springframework.core.convert.ConversionService)3 MifosBeanValidator (org.mifos.platform.validation.MifosBeanValidator)2 StubValidationContext (org.mifos.ui.validation.StubValidationContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 FormattingConversionService (org.springframework.format.support.FormattingConversionService)2 RequestMappingHandlerAdapter (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter)2 FAIL_ON_UNKNOWN_PROPERTIES (com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)1 DEFAULT_VIEW_INCLUSION (com.fasterxml.jackson.databind.MapperFeature.DEFAULT_VIEW_INCLUSION)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 List (java.util.List)1 Locale (java.util.Locale)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 DateTime (org.joda.time.DateTime)1