TargetInstanceGeneralHandler extends TabHandler { public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_EDIT)) { TargetInstance ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); if (ti == null) { ti = targetInstanceManager.getTargetInstance(cmd.getTargetInstanceId(), true); } ti.setBandwidthPercent(cmd.getBandwidthPercent()); ti.setPriority(cmd.getPriority()); User owner = agencyUserManager.getUserByUserName(cmd.getOwner()); ti.setOwner(owner); ti.setScheduledTime(cmd.getScheduledTime()); ti.setFlagged(cmd.getFlagged()); if (enableQaModule) { if (cmd.getFlagOid() != null) { Flag flag = agencyUserManager.getFlagByOid(cmd.getFlagOid()); ti.setFlag(flag); } else { ti.setFlag(null); } } ti.setUseAQA(cmd.isUseAQA()); req.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, ti); } }  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 testProcessTab() { 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_EDIT); aCmd.setFlagged(true); BindException aErrors = new BindException(aCmd, aCmd.getCmd()); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(targetInstance.getFlagged()); currentTab = tabs.get(0); aCmd.setCmd(TargetInstanceCommand.ACTION_EDIT); aCmd.setFlagged(false); aErrors = new BindException(aCmd, aCmd.getCmd()); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertFalse(targetInstance.getFlagged()); }