GeneralHandler extends AbstractGroupTabHandler { @Override public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { GeneralCommand command = (GeneralCommand) comm; GroupsEditorContext ctx = getEditorContext(req); TargetGroup target = ctx.getTargetGroup(); if(ctx.isEditMode()) { if( authorityManager.hasPrivilege(target, Privilege.CREATE_GROUP)) { String previousName = target.getName(); target.setName(command.getName()); target.setDescription(command.getDescription()); target.setSipType(command.getSipType()); target.setOwnershipMetaData(command.getOwnershipMetaData()); target.setFromDate(command.getFromDate()); target.setToDate(command.getToDate()); target.setReferenceNumber(command.getReference()); target.setType(command.getType()); if(previousName == null || !previousName.equals(target.getName())) { DublinCore dc = target.getDublinCoreMetaData(); if(dc == null) { dc = new DublinCore(); target.setDublinCoreMetaData(dc); } String title = dc.getTitle(); if(title == null || title.isEmpty() || title.equals(previousName)) { dc.setTitle(target.getName()); } } if(subGroupTypeName.equals(target.getType())) { try { Long parentOid = Long.parseLong(command.getParentOid()); setParent(req, parentOid); } catch(NumberFormatException e) { } String parentName = getParentName(req); if(parentName != null && !parentName.isEmpty()) { String name = parentName + subGroupSeparator + command.getName(); target.setName(name); } } } if(authorityManager.hasPrivilege(target, Privilege.TAKE_OWNERSHIP)) { User newOwner = agencyUserManager.getUserByOid(command.getOwnerOid()); if(agencyUserManager.canGiveTo(target, newOwner)) { target.setOwner(newOwner); } } } }  @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 testProcessTab() { 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); aCmd.setName("TestName"); aCmd.setFromDate(null); BindException aErrors = new BindException(aCmd, "GeneralCommand"); this.addCurrentUserPrivilege("CREATE_GROUP"); this.addCurrentUserPrivilege("TAKE_OWNERSHIP"); assertTrue(targetGroup.getDublinCoreMetaData() != null); assertTrue(targetGroup.getDublinCoreMetaData().getTitle().isEmpty()); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(targetGroup.getName().equals("TestName")); assertTrue(targetGroup.getFromDate() == null); assertTrue(targetGroup.getDublinCoreMetaData() != null); assertEquals(targetGroup.getDublinCoreMetaData().getTitle(),"TestName"); aCmd.setName("TestName2"); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(targetGroup.getName().equals("TestName2")); assertTrue(targetGroup.getDublinCoreMetaData() != null); assertEquals(targetGroup.getDublinCoreMetaData().getTitle(),"TestName2"); targetGroup.getDublinCoreMetaData().setTitle("TestName4"); aCmd.setName("TestName3"); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertTrue(targetGroup.getName().equals("TestName3")); assertTrue(targetGroup.getDublinCoreMetaData() != null); assertEquals(targetGroup.getDublinCoreMetaData().getTitle(),"TestName4"); }