AnnotationAjaxController extends AbstractFormController { @Override protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object aCmd, BindException aErrors) throws Exception { String ajaxRequest = request.getParameter(Constants.AJAX_REQUEST_TYPE); if (ajaxRequest.equals(Constants.AJAX_REQUEST_FOR_TI_ANNOTATIONS)) { return processTargetInstanceRequest(request, response, aCmd, aErrors); } if (ajaxRequest.equals(Constants.AJAX_REQUEST_FOR_TARGET_ANNOTATIONS)) { return processTargetRequest(request, response, aCmd, aErrors); } return null; } AnnotationAjaxController(); void setTargetInstanceManager(TargetInstanceManager aTargetInstanceManager); void setTargetManager(TargetManager targetManager);  }
@Test public final void testProcessFormSubmissionTargetInstanceRequest() { try { MockHttpServletRequest aReq = new MockHttpServletRequest(); HttpServletResponse aResp = new MockHttpServletResponse(); TargetInstanceCommand aCmd = new TargetInstanceCommand(); aCmd.setCmd(TargetInstanceCommand.SESSION_TI_SEARCH_CRITERIA); aReq.getSession().setAttribute(TargetInstanceCommand.SESSION_TI_SEARCH_CRITERIA, new TargetInstanceCommand()); aReq.setParameter("targetOid", "0"); aReq.setParameter("targetInstanceOid", "1"); BindException aErrors = new BindException(aCmd, TargetInstanceCommand.SESSION_TI_SEARCH_CRITERIA); aReq.setParameter(Constants.AJAX_REQUEST_TYPE, Constants.AJAX_REQUEST_FOR_TI_ANNOTATIONS); ModelAndView mav = testInstance.processFormSubmission(aReq, aResp, aCmd, aErrors); assertTrue(mav != null); assertTrue(mav.getViewName().equals(Constants.VIEW_TI_ANNOTATION_HISTORY)); assertFalse(aErrors.hasErrors()); } catch(Exception e) { fail(e.getMessage()); } }