Search in sources :

Example 6 with WebExchangeDataBinder

use of org.springframework.web.bind.support.WebExchangeDataBinder in project spring-framework by spring-projects.

the class ControllerAdviceTests method initBinderAdvice.

@Test
public void initBinderAdvice() throws Exception {
    ApplicationContext context = new AnnotationConfigApplicationContext(TestConfig.class);
    RequestMappingHandlerAdapter adapter = createAdapter(context);
    TestController controller = context.getBean(TestController.class);
    Validator validator = mock(Validator.class);
    controller.setValidator(validator);
    BindingContext bindingContext = handle(adapter, controller, "handle").getBindingContext();
    WebExchangeDataBinder binder = bindingContext.createDataBinder(this.exchange, "name");
    assertEquals(Collections.singletonList(validator), binder.getValidators());
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) BindingContext(org.springframework.web.reactive.BindingContext) WebExchangeDataBinder(org.springframework.web.bind.support.WebExchangeDataBinder) Validator(org.springframework.validation.Validator) Test(org.junit.Test)

Example 7 with WebExchangeDataBinder

use of org.springframework.web.bind.support.WebExchangeDataBinder in project spring-framework by spring-projects.

the class ErrorsArgumentResolverTests method setup.

@Before
public void setup() throws Exception {
    this.resolver = new ErrorsMethodArgumentResolver(new ReactiveAdapterRegistry());
    Foo foo = new Foo();
    WebExchangeDataBinder binder = this.bindingContext.createDataBinder(this.exchange, foo, "foo");
    this.bindingResult = binder.getBindingResult();
}
Also used : ReactiveAdapterRegistry(org.springframework.core.ReactiveAdapterRegistry) WebExchangeDataBinder(org.springframework.web.bind.support.WebExchangeDataBinder) Before(org.junit.Before)

Aggregations

WebExchangeDataBinder (org.springframework.web.bind.support.WebExchangeDataBinder)7 BindingContext (org.springframework.web.reactive.BindingContext)4 Test (org.junit.Test)3 ReactiveAdapterRegistry (org.springframework.core.ReactiveAdapterRegistry)3 Validator (org.springframework.validation.Validator)3 Mono (reactor.core.publisher.Mono)3 Map (java.util.Map)2 BeanUtils (org.springframework.beans.BeanUtils)2 ApplicationContext (org.springframework.context.ApplicationContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 MethodParameter (org.springframework.core.MethodParameter)2 ReactiveAdapter (org.springframework.core.ReactiveAdapter)2 ResolvableType (org.springframework.core.ResolvableType)2 Model (org.springframework.ui.Model)2 Assert (org.springframework.util.Assert)2 ClassUtils (org.springframework.util.ClassUtils)2 StringUtils (org.springframework.util.StringUtils)2 BindingResult (org.springframework.validation.BindingResult)2 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)2 WebBindingInitializer (org.springframework.web.bind.support.WebBindingInitializer)2