CustomDepositFormController extends AbstractCommandController { @Override protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object comm, BindException errors) throws Exception { ArchiveCommand command = (ArchiveCommand) comm; ModelAndView mav = new ModelAndView("deposit-form-envelope"); mav.addObject(Constants.GBL_CMD_DATA, command); return mav; } CustomDepositFormController();   }
@Test public void testHandleHttpServletRequestHttpServletResponseObjectBindException() { MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); ArchiveCommand comm = new ArchiveCommand(); comm.setHarvestResultNumber(1); comm.setTargetInstanceID(5001); BindException errors = new BindException(comm, "ArchiveCommand"); ModelAndView mav = null;; try { mav = testInstance.handle(request, response, comm, errors); } catch (Exception e) { fail(e.getMessage()); return; } assertNotNull(mav); assertEquals("deposit-form-envelope", mav.getViewName()); assertNotNull(mav.getModel().get(Constants.GBL_CMD_DATA)); assertEquals(1, ((ArchiveCommand)mav.getModel().get(Constants.GBL_CMD_DATA)).getHarvestResultNumber()); assertEquals(5001, ((ArchiveCommand)mav.getModel().get(Constants.GBL_CMD_DATA)).getTargetInstanceID()); assertNull(mav.getModel().get("hasErrors")); }