QueueController extends AbstractFormController { @Override protected ModelAndView showForm(HttpServletRequest aReq, HttpServletResponse aResp, BindException aErrors) throws Exception { cleanSession(aReq); return processFilter(aReq, aResp, null, aErrors); } QueueController(); void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); void setTargetInstanceManager(TargetInstanceManager aTargetInstanceManager); void setHarvestCoordinator(HarvestCoordinator harvestCoordinator); void setEnvironment(Environment environment); void setAgencyUserManager(AgencyUserManager agencyUserManager); void setMessageSource(MessageSource messageSource); void setEnableQaModule(Boolean enableQaModule); void setThumbnailWidth(String thumbnailWidth); void setThumbnailHeight(String thumbnailHeight); void setThumbnailRenderer(String thumbnailRenderer); void setHarvestResourceUrlMapper(HarvestResourceUrlMapper harvestResourceUrlMapper);  }
@Test public final void testShowForm() throws Exception { HttpSession session = mockRequest.getSession(); session.setAttribute(TargetInstanceCommand.SESSION_TI, "test2"); session.setAttribute(TargetInstanceCommand.SESSION_MODE, "test3"); session.setAttribute(Constants.GBL_SESS_EDIT_MODE, "test4"); ModelAndView mav = testInstance.showForm(mockRequest, mockResponse, errors); assertNotNull(mav); TargetInstanceCommand command = (TargetInstanceCommand) mav.getModel().get("command"); assertEquals(TargetInstanceCommand.ACTION_FILTER, command.getCmd()); assertFalse(command.getFlagged()); assertTrue(mav.getViewName().equals(Constants.VIEW_TARGET_INSTANCE_QUEUE)); assertFalse(errors.hasErrors()); assertNull(mockRequest.getAttribute(TargetInstanceCommand.SESSION_TI_SEARCH_CRITERIA)); assertNull(session.getAttribute(TargetInstanceCommand.SESSION_TI)); assertNull(session.getAttribute(TargetInstanceCommand.SESSION_MODE)); assertNull(session.getAttribute(Constants.GBL_SESS_EDIT_MODE)); }
@Test public final void testShowFormHarvested() throws Exception { mockRequest.addParameter(TargetInstanceCommand.REQ_TYPE, TargetInstanceCommand.TYPE_HARVESTED); ModelAndView mav = testInstance.showForm(mockRequest, mockResponse, errors); assertNotNull(mav); TargetInstanceCommand command = (TargetInstanceCommand) mav.getModel().get("command"); assertEquals(TargetInstanceCommand.ACTION_FILTER, command.getCmd()); assertFalse(command.getFlagged()); assertTrue(mav.getViewName().equals(Constants.VIEW_TARGET_INSTANCE_QUEUE)); assertFalse(errors.hasErrors()); assertEquals(command.getOwner(), AuthUtil.getRemoteUser()); assertEquals(command.getAgency(), AuthUtil.getRemoteUserObject().getAgency().getName()); assertTrue(command.getStates().size() == 1); assertTrue(command.getStates().iterator().next() == TargetInstance.STATE_HARVESTED); assertNull(mockRequest.getAttribute(TargetInstanceCommand.SESSION_TI_SEARCH_CRITERIA)); }
@Test public final void testShowFormTarget() throws Exception { mockRequest.addParameter(TargetInstanceCommand.REQ_TYPE, TargetInstanceCommand.TYPE_TARGET); mockRequest.addParameter(TargetInstanceCommand.PARAM_TARGET_NAME, "TestName"); ModelAndView mav = testInstance.showForm(mockRequest, mockResponse, errors); assertNotNull(mav); TargetInstanceCommand command = (TargetInstanceCommand) mav.getModel().get("command"); assertEquals(TargetInstanceCommand.ACTION_FILTER, command.getCmd()); assertFalse(command.getFlagged()); assertTrue(mav.getViewName().equals(Constants.VIEW_TARGET_INSTANCE_QUEUE)); assertFalse(errors.hasErrors()); assertEquals(command.getName(), "TestName"); assertEquals(0, command.getStates().size()); }