use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ModelAndViewResolverMethodReturnValueHandlerTests method setup.
@BeforeEach
public void setup() {
mavResolvers = new ArrayList<>();
handler = new ModelAndViewResolverMethodReturnValueHandler(mavResolvers);
mavContainer = new ModelAndViewContainer();
request = new ServletWebRequest(new MockHttpServletRequest());
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ViewMethodReturnValueHandlerTests method setup.
@BeforeEach
public void setup() {
this.handler = new ViewMethodReturnValueHandler();
this.mavContainer = new ModelAndViewContainer();
this.webRequest = new ServletWebRequest(new MockHttpServletRequest());
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ModelAttributeMethodProcessorTests method setup.
@BeforeEach
public void setup() throws Exception {
this.request = new ServletWebRequest(new MockHttpServletRequest());
this.container = new ModelAndViewContainer();
this.processor = new ModelAttributeMethodProcessor(false);
Method method = ModelAttributeHandler.class.getDeclaredMethod("modelAttribute", TestBean.class, Errors.class, int.class, TestBean.class, TestBean.class, TestBean.class, TestBeanWithConstructorArgs.class);
this.paramNamedValidModelAttr = new SynthesizingMethodParameter(method, 0);
this.paramErrors = new SynthesizingMethodParameter(method, 1);
this.paramInt = new SynthesizingMethodParameter(method, 2);
this.paramModelAttr = new SynthesizingMethodParameter(method, 3);
this.paramBindingDisabledAttr = new SynthesizingMethodParameter(method, 4);
this.paramNonSimpleType = new SynthesizingMethodParameter(method, 5);
this.beanWithConstructorArgs = new SynthesizingMethodParameter(method, 6);
method = getClass().getDeclaredMethod("annotatedReturnValue");
this.returnParamNamedModelAttr = new MethodParameter(method, -1);
method = getClass().getDeclaredMethod("notAnnotatedReturnValue");
this.returnParamNonSimpleType = new MethodParameter(method, -1);
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ModelFactoryTests method updateModelSessionAttributesRemoved.
@Test
public void updateModelSessionAttributesRemoved() throws Exception {
String attributeName = "sessionAttr";
String attribute = "value";
ModelAndViewContainer container = new ModelAndViewContainer();
container.addAttribute(attributeName, attribute);
this.attributeStore.storeAttribute(this.webRequest, attributeName, attribute);
WebDataBinder dataBinder = new WebDataBinder(attribute, attributeName);
WebDataBinderFactory binderFactory = mock(WebDataBinderFactory.class);
given(binderFactory.createBinder(this.webRequest, attribute, attributeName)).willReturn(dataBinder);
container.getSessionStatus().setComplete();
ModelFactory modelFactory = new ModelFactory(null, binderFactory, this.attributeHandler);
modelFactory.updateModel(this.webRequest, container);
assertThat(container.getModel().get(attributeName)).isEqualTo(attribute);
assertThat(this.attributeStore.retrieveAttribute(this.webRequest, attributeName)).isNull();
}
use of org.springframework.web.method.support.ModelAndViewContainer in project spring-framework by spring-projects.
the class ReactiveTypeHandlerTests method handleValue.
private ResponseBodyEmitter handleValue(Object returnValue, Class<?> asyncType, ResolvableType genericType) throws Exception {
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
MethodParameter returnType = on(TestController.class).resolveReturnType(asyncType, genericType);
return this.handler.handleValue(returnValue, returnType, mavContainer, this.webRequest);
}
Aggregations