### Question:
SecuredController extends UIController { @Override protected final ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { ModelAndView mav = Constants.REDIRECTION_TO_LOGIN; ApplicationState state = getApplicationState(request); User currentUser = state.getCurrentUser(); if (currentUser != null) { if (_defaultAction == null) { mav = securedShowForm(request, response, errors); } else { Action<Object> action = instantiateDefaultAction(); action.setRequest(request); action.setResponse(response); action.setCommand(getCommand(request)); action.setBindErrors(errors); mav = action.doExecution(); } } fillAuthorization(request, mav); state.setPreviousAction(request.getRequestURL().append("?").append(request.getQueryString()).toString()); return mav; }  static String getCurrentUserName(HttpServletRequest request);  }### Answer:
@Test public void testShowFormWithoutUser() throws Exception { securedController = (SecuredController) context.getBean("tasksController"); ModelAndView mav = securedController.showForm(request, response, null); Assert.assertTrue(mav.getView().toString().contains(Constants.LOGIN_URL)); }
@Test public void testShowFormWithUser() throws Exception { FakeUIFWApplicationState state = new FakeUIFWApplicationState(); User currentUser = new User("test1", new String[] { "test/test1" }, "token1"); state.setCurrentUser(currentUser); request.getSession().setAttribute("APPLICATION_STATE", state); securedController = (SecuredController) context.getBean("tasksController"); ModelAndView mav = securedController.showForm(request, response, new BindException(currentUser, "test")); Assert.assertEquals(mav.getViewName(), "tasks"); }