@Test public void resolveArgumentOrdering() throws Exception { String name = "testBean"; Object testBean = new TestBean(name); mavContainer.addAttribute(name, testBean); mavContainer.addAttribute(BindingResult.MODEL_KEY_PREFIX + name, testBean); Object anotherTestBean = new TestBean(); mavContainer.addAttribute("anotherTestBean", anotherTestBean); StubRequestDataBinder dataBinder = new StubRequestDataBinder(testBean, name); WebDataBinderFactory binderFactory = createMock(WebDataBinderFactory.class); expect(binderFactory.createBinder(webRequest, testBean, name)).andReturn(dataBinder); replay(binderFactory); processor.resolveArgument(paramModelAttr, mavContainer, webRequest, binderFactory); assertSame( "Resolved attribute should be updated to be last in the order", testBean, mavContainer.getModel().values().toArray()[1]); assertSame( "BindingResult of resolved attribute should be last in the order", dataBinder.getBindingResult(), mavContainer.getModel().values().toArray()[2]); }
@Test public void handleNotAnnotatedReturnValue() throws Exception { TestBean testBean = new TestBean("expected"); processor.handleReturnValue(testBean, returnParamNonSimpleType, mavContainer, webRequest); assertSame(testBean, mavContainer.getModel().get("testBean")); }