GeneralHandler extends AbstractGroupTabHandler { @Override public TabbedModelAndView preProcessNextTab(TabbedController tc, Tab nextTabID, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { TargetGroup aTargetGroup = getEditorContext(req).getTargetGroup(); GeneralCommand command = GeneralCommand.buildFromModel(aTargetGroup, subGroupTypeName, subGroupSeparator); if(comm instanceof AddParentsCommand) { AddParentsCommand addParentsCommand = (AddParentsCommand)comm; if(AddParentsCommand.ACTION_ADD_PARENTS.equals(addParentsCommand.getActionCmd())) { long[] parentOids = addParentsCommand.getParentOids(); if(parentOids != null && parentOids.length > 0) { long parentOid = parentOids[0]; TargetGroup parentGroup = targetManager.loadGroup(parentOid, false); command.setParentOid(Long.toString(parentOid)); command.setParentName(parentGroup.getName()); command.setType(subGroupTypeName); } else { command.setParentOid(""); command.setParentName(""); command.setType(subGroupTypeName); } } else if(AddParentsCommand.ACTION_CANCEL.equals(addParentsCommand.getActionCmd())) { Long parentOid = getParent(req); if(parentOid != null) { command.setParentOid(getParent(req).toString()); command.setParentName(getParentName(req)); } else { command.setParentOid(""); command.setParentName(""); } command.setType(subGroupTypeName); } } else { Long parentOid = getParent(req); command.setParentOid(parentOid == null?"":parentOid.toString()); String parentName = getParentName(req); command.setParentName(parentName); } if(subGroupTypeName.equals(aTargetGroup.getType())) { if(aTargetGroup.getName().contains(subGroupSeparator)) { command.setName(aTargetGroup.getName().substring(aTargetGroup.getName().indexOf(subGroupSeparator)+subGroupSeparator.length())); } } List<UserDTO> users = agencyUserManager.getPossibleOwners(aTargetGroup); TabbedModelAndView tmav = tc.new TabbedModelAndView(); tmav.addObject(Constants.GBL_CMD_DATA, command); tmav.addObject("allUsers", users); tmav.addObject("groupTypesList", getGroupTypes(req)); return tmav; }  @Override void initBinder(HttpServletRequest request, ServletRequestDataBinder binder); void setAuthorityManager(AuthorityManager authorityManager); @Override void processTab(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); @Override TabbedModelAndView preProcessNextTab(TabbedController tc,
			Tab nextTabID, HttpServletRequest req, HttpServletResponse res,
			Object comm, BindException errors); @Override ModelAndView processOther(TabbedController tc, Tab currentTab,
			HttpServletRequest req, HttpServletResponse res, Object comm,
			BindException errors); void setAgencyUserManager(AgencyUserManager agencyUserManager); void setTargetManager(TargetManager targetManager); void setGroupTypesList(WCTTreeSet groupTypesList); void setSubGroupTypeName(String subGroupTypeName); void setSubGroupSeparator(String subGroupSeparator);  }
@Test public final void testPreProcessNextTab() { HttpServletRequest aReq = new MockHttpServletRequest(); TargetManager targetManager = new MockTargetManager(testFile); testInstance.setTargetManager(targetManager); testSetAuthorityManager(); testSetAgencyUserManager(); testSetGroupTypesList(); testSetSubGroupTypeName(); TargetGroup targetGroup = targetManager.loadGroup(15000L); GroupsEditorContext groupsEditorContext = new GroupsEditorContext(targetGroup,true); aReq.getSession().setAttribute(TabbedGroupController.EDITOR_CONTEXT, groupsEditorContext); HttpServletResponse aResp = new MockHttpServletResponse(); GeneralCommand aCmd = new GeneralCommand(); TabbedController tc = new TabbedGroupController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("group"); List<Tab> tabs = getTabList(targetManager); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); tc.setDefaultCommandClass(org.webcurator.ui.groups.command.DefaultCommand.class); Tab currentTab = tabs.get(0); BindException aErrors = new BindException(aCmd, "GeneralCommand"); ModelAndView mav = testInstance.preProcessNextTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(((GeneralCommand)mav.getModel().get("command")).getName() == targetGroup.getName()); assertTrue(((GeneralCommand)mav.getModel().get("command")).getFromDate().equals(targetGroup.getFromDate())); }