@Test public final void testProcessTab() throws Exception { HttpServletRequest aReq = new MockHttpServletRequest(); TargetInstanceManager targetInstanceManager = new MockTargetInstanceManager(testFile); testInstance.setTargetInstanceManager(targetInstanceManager); TargetInstance targetInstance = targetInstanceManager.getTargetInstance(5000L); List<Annotation> list = createAnnotationList(); assertFalse(checkSortedList(list)); targetInstance.setAnnotations(list); aReq.getSession().setAttribute(TargetInstanceCommand.SESSION_TI, targetInstance); HttpServletResponse aResp = new MockHttpServletResponse(); TargetInstanceCommand aCmd = new TargetInstanceCommand(); TabbedController tc = new TabbedTargetInstanceController(); TabConfig tabConfig = new TabConfig(); tabConfig.setViewName("targetInstance"); List<Tab> tabs = getTabList(targetInstanceManager); tabConfig.setTabs(tabs); tc.setTabConfig(tabConfig); tc.setDefaultCommandClass(org.webcurator.ui.target.command.TargetInstanceCommand.class); Tab currentTab = tabs.get(1); aCmd.setCmd(TargetInstanceCommand.ACTION_ADD_NOTE); aCmd.setNote("A note"); BindException aErrors = new BindException(aCmd, aCmd.getCmd()); List<Annotation> resultAnnotations = targetInstance.getAnnotations(); int numAnnotations = resultAnnotations.size(); testInstance.processTab(tc, currentTab, aReq, aResp, aCmd, aErrors); assertEquals(resultAnnotations.size(), numAnnotations+1); Annotation resultAnnotation = resultAnnotations.get(resultAnnotations.size()-1); assertEquals("A note", resultAnnotation.getNote()); }
public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { if (comm instanceof TargetInstanceCommand) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_ADD_NOTE)) { TargetInstance ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); addAnnotation(cmd, ti); } } }
TargetInstanceAnnotationHandler extends TabHandler { public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { if (comm instanceof TargetInstanceCommand) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_ADD_NOTE)) { TargetInstance ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); addAnnotation(cmd, ti); } } } }
TargetInstanceAnnotationHandler extends TabHandler { public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { if (comm instanceof TargetInstanceCommand) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_ADD_NOTE)) { TargetInstance ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); addAnnotation(cmd, ti); } } }  }
TargetInstanceAnnotationHandler extends TabHandler { public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { if (comm instanceof TargetInstanceCommand) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_ADD_NOTE)) { TargetInstance ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); addAnnotation(cmd, ti); } } }  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 setTargetInstanceManager(TargetInstanceManager targetInstanceManager); }
TargetInstanceAnnotationHandler extends TabHandler { public void processTab(TabbedController tc, Tab currentTab, HttpServletRequest req, HttpServletResponse res, Object comm, BindException errors) { if (comm instanceof TargetInstanceCommand) { TargetInstanceCommand cmd = (TargetInstanceCommand) comm; cmd = (TargetInstanceCommand) comm; if (cmd.getCmd().equals(TargetInstanceCommand.ACTION_ADD_NOTE)) { TargetInstance ti = (TargetInstance) req.getSession().getAttribute(TargetInstanceCommand.SESSION_TI); addAnnotation(cmd, ti); } } }  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 setTargetInstanceManager(TargetInstanceManager targetInstanceManager);  }