Search in sources :

Example 6 with LocalValidatorFactoryBean

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

the class DelegatingWebMvcConfigurationTests method getCustomValidator.

@Test
public void getCustomValidator() {
    given(webMvcConfigurer.getValidator()).willReturn(new LocalValidatorFactoryBean());
    delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer));
    delegatingConfig.mvcValidator();
    verify(webMvcConfigurer).getValidator();
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Test(org.junit.Test)

Example 7 with LocalValidatorFactoryBean

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

the class DelegatingWebMvcConfigurationTests method requestMappingHandlerAdapter.

@Test
public void requestMappingHandlerAdapter() throws Exception {
    delegatingConfig.setConfigurers(Collections.singletonList(webMvcConfigurer));
    RequestMappingHandlerAdapter adapter = delegatingConfig.requestMappingHandlerAdapter();
    ConfigurableWebBindingInitializer initializer = (ConfigurableWebBindingInitializer) adapter.getWebBindingInitializer();
    ConversionService initializerConversionService = initializer.getConversionService();
    assertTrue(initializer.getValidator() instanceof LocalValidatorFactoryBean);
    verify(webMvcConfigurer).configureMessageConverters(converters.capture());
    verify(webMvcConfigurer).configureContentNegotiation(contentNegotiationConfigurer.capture());
    verify(webMvcConfigurer).addFormatters(conversionService.capture());
    verify(webMvcConfigurer).addArgumentResolvers(resolvers.capture());
    verify(webMvcConfigurer).addReturnValueHandlers(handlers.capture());
    verify(webMvcConfigurer).configureAsyncSupport(asyncConfigurer.capture());
    assertSame(conversionService.getValue(), initializerConversionService);
    assertEquals(0, resolvers.getValue().size());
    assertEquals(0, handlers.getValue().size());
    assertEquals(converters.getValue(), adapter.getMessageConverters());
    assertNotNull(asyncConfigurer);
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) ConfigurableWebBindingInitializer(org.springframework.web.bind.support.ConfigurableWebBindingInitializer) ConversionService(org.springframework.core.convert.ConversionService) FormattingConversionService(org.springframework.format.support.FormattingConversionService) RequestMappingHandlerAdapter(org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter) Test(org.junit.Test)

Example 8 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project SpringStepByStep by JavaProgrammerLB.

the class MvcConfig method getValidator.

@Override
public Validator getValidator() {
    LocalValidatorFactoryBean factory = new LocalValidatorFactoryBean();
    factory.setValidationMessageSource(messageSource);
    return factory;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 9 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project camel by apache.

the class CamelTestConfiguration method getValidatorFactory.

@Bean
public LocalValidatorFactoryBean getValidatorFactory() {
    final LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.getValidationPropertyMap().put("hibernate.validator.fail_fast", "true");
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 10 with LocalValidatorFactoryBean

use of org.springframework.validation.beanvalidation.LocalValidatorFactoryBean in project camel by apache.

the class ValidatorConfiguration method getValidatorFactory.

@Bean
public LocalValidatorFactoryBean getValidatorFactory() {
    final LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
    localValidatorFactoryBean.getValidationPropertyMap().put("hibernate.validator.fail_fast", "true");
    return localValidatorFactoryBean;
}
Also used : LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean) Bean(org.springframework.context.annotation.Bean) 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