TargetInstanceGeneralHandler extends TabHandler { public ModelAndView processOther(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_HARVEST)) { HashMap<String, HarvestAgentStatusDTO> agents = harvestCoordinator.getHarvestAgents(); TargetInstance ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId()); String instanceAgency = ti.getOwner().getAgency().getName(); String key = ""; HarvestAgentStatusDTO agent = null; HashMap<String, HarvestAgentStatusDTO> allowedAgents = new HashMap<String, HarvestAgentStatusDTO>(); Iterator<String> it = agents.keySet().iterator(); while (it.hasNext()) { key = (String) it.next(); agent = agents.get(key); if (agent.getAllowedAgencies().contains(instanceAgency) || agent.getAllowedAgencies().isEmpty()) { allowedAgents.put(key, agent); } } ModelAndView mav = new ModelAndView(); mav.addObject(TargetInstanceCommand.MDL_INSTANCE, ti); mav.addObject(Constants.GBL_CMD_DATA, cmd); mav.addObject(TargetInstanceCommand.MDL_AGENTS, allowedAgents); mav.setViewName(Constants.VIEW_HARVEST_NOW); return mav; } else { throw new WCTRuntimeException("Unknown command " + cmd.getCmd() + " recieved."); } }  void setAuthorityManager(AuthorityManager authorityManager); void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); void processTab(TabbedController tc, Tab currentTab,
            HttpServletRequest req, HttpServletResponse res, Object comm,
            BindException errors); @SuppressWarnings("unchecked") TabbedModelAndView preProcessNextTab(TabbedController tc,
            Tab nextTabID, HttpServletRequest req, HttpServletResponse res,
            Object comm, BindException errors); ModelAndView processOther(TabbedController tc, Tab currentTab,
            HttpServletRequest req, HttpServletResponse res, Object comm,
            BindException errors); void setHarvestCoordinator(HarvestCoordinator harvestCoordinator); void setTargetInstanceManager(TargetInstanceManager targetInstanceManager); void setAgencyUserManager(AgencyUserManager agencyUserManager); void setAutoQAUrl(String autoQAUrl); String getAutoQAUrl(); void setEnableQaModule(Boolean enableQaModule);  }
@Test public final void testProcessOther() { HttpServletRequest aReq = new MockHttpServletRequest(); testSetAgencyUserManager(); testSetAuthorityManager(); testSetHarvestCoordinator(); testSetTargetInstanceManager(); TargetInstance targetInstance = getTargetInstanceManager().getTargetInstance(5001L); aReq.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, targetInstance); aReq.getSession().setAttribute(TargetInstanceCommand.SESSION_MODE, true); HttpServletResponse aResp = new MockHttpServletResponse(); TargetInstanceCommand aCmd = new TargetInstanceCommand(targetInstance); TabbedController tc = new TabbedTargetInstanceController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("targetInstance"); List<Tab> tabs = getTabList(); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); tc.setDefaultCommandClass(org.webcurator.ui.target.command.TargetInstanceCommand.class); Tab currentTab = tabs.get(0); aCmd.setCmd(TargetInstanceCommand.ACTION_HARVEST); BindException aErrors = new BindException(aCmd, aCmd.getCmd()); ModelAndView mav = testInstance.processOther(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(mav != null); try { aCmd.setCmd(TargetInstanceCommand.ACTION_EDIT); aErrors = new BindException(aCmd, aCmd.getCmd()); testInstance.processOther(tc, currentTab, aReq, aResp, aCmd, aErrors); fail("Exception not thrown for unknown command"); } catch(WCTRuntimeException re) { assertTrue(re.getMessage().startsWith("Unknown command ")); } catch(Exception e) { fail("Unexpected Exception: "+e.getMessage()); } }