AddColumnAction extends InterMineAction { @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String columnToAdd = request.getParameter("columnToAdd"); HttpSession session = request.getSession(); String tableId = request.getParameter("table"); PagedTable pt = SessionMethods.getResultsTable(session, tableId); if (columnToAdd != null && columnToAdd.length() != 0) { changeView(pt.getWebTable(), columnToAdd, request); } return new ForwardParameters(mapping.findForward("results")) .addParameter("table", tableId) .addParameter("page", "" + pt.getPage()) .addParameter("trail", request.getParameter("trail")).forward(); }  @Override ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response);  }
@Test public void testExecute() throws Exception { HttpServletRequest request = createMock(HttpServletRequest.class); HttpSession session = createMock(HttpSession.class); InterMineAPI api = createMock(InterMineAPI.class); ServletContext servletContext = createMock(ServletContext.class); WebTable webTable = createMock(WebTable.class); @SuppressWarnings("deprecation") PagedTable table = new PagedTable(webTable); @SuppressWarnings("deprecation") Map<String, PagedTable> tableMap = new HashMap<String, PagedTable>(); tableMap.put("y", table); Model model = Model.getInstanceByName("testmodel"); PathQuery pathQuery = new PathQuery(model); pathQuery.addView("Employee.name"); ActionMapping mapping = new ActionMapping(); AddColumnAction action = new AddColumnAction(); List<Path> columnsPath = new ArrayList<Path>(); ForwardConfig conf = new ActionForward(); conf.setName("results"); conf.setPath("thataway"); mapping.addForwardConfig(conf); expect(request.getParameter("columnToAdd")).andReturn("Employee.age"); expect(request.getSession()).andReturn(session).times(2); expect(request.getParameter("table")).andReturn("y"); expect(request.getParameter("trail")).andReturn("zoom"); expect(session.getAttribute("TABLE_MAP")).andReturn(tableMap); expect(webTable.getPathQuery()).andReturn(pathQuery).times(2); expect(session.getServletContext()).andReturn(servletContext); expect(servletContext.getAttribute("INTERMINE_API")).andReturn(api); expect(api.getModel()).andReturn(model); expect(webTable.getColumnsPath()).andReturn(columnsPath); webTable.addColumns(Arrays.asList(new Path(model, "Employee.age"))); replay(request); replay(session); replay(webTable); replay(api); replay(servletContext); ActionForward fwd = action.execute(mapping, null, request, null); verify(request); verify(session); verify(webTable); verify(api); verify(servletContext); assertEquals(Arrays.asList("Employee.name", "Employee.age"), pathQuery.getView()); assertEquals("thataway?table=y&page=0&trail=zoom", fwd.getPath()); }