### Question:
Login { @RequestMapping(value = "/logout") public ModelAndView logout(@RequestParam(value="SAMLRequest", required=false) String encodedSamlRequest, @RequestParam(value = "realm", required = false) String realm, @RequestParam(value = "developer", required = false) String developer, HttpSession httpSession) { httpSession.removeAttribute(USER_SESSION_KEY); if(encodedSamlRequest!=null){ ModelAndView mav = form(encodedSamlRequest, realm, developer, httpSession); mav.addObject("msg", "You are now logged out"); return mav; }else{ return new ModelAndView("loggedOut"); } }  @RequestMapping(value = "/logout") ModelAndView logout(@RequestParam(value="SAMLRequest", required=false) String encodedSamlRequest,
            @RequestParam(value = "realm", required = false) String realm,
            @RequestParam(value = "developer", required = false) String developer,
            HttpSession httpSession); @RequestMapping(value = "/", method = RequestMethod.GET) ModelAndView form(@RequestParam("SAMLRequest") String encodedSamlRequest,
            @RequestParam(value = "realm", required = false) String realm,
            @RequestParam(value = "developer", required = false) String developer,
            HttpSession httpSession); @RequestMapping(value= "/admin", method = RequestMethod.POST) ModelAndView admin(@RequestParam("SAMLRequest") String encodedSamlRequest,
            @RequestParam(value = "realm", required = false) String realm, HttpSession httpSession); @RequestMapping(value = "/login", method = RequestMethod.POST) ModelAndView login(
            @RequestParam("user_id") String userId,
            @RequestParam("password") String password,
            @RequestParam("SAMLRequest") String encodedSamlRequest,
            @RequestParam(value = "realm", required = false) String realm,
            @RequestParam(value = "developer", required = false) String developer,
            HttpSession httpSession,
            HttpServletRequest request); @SuppressWarnings({ "unchecked", "rawtypes" }) @RequestMapping(value = "/impersonate", method = RequestMethod.POST) ModelAndView impersonate(
            @RequestParam("SAMLRequest") String encodedSamlRequest,
            @RequestParam(value = "realm", required = false) String realm,
            @RequestParam(value = "impersonate_user", required = false) String impersonateUser,
            @RequestParam(value = "selected_roles", required = false) List<String> roles,
            @RequestParam(value = "customRoles", required = false) String customRoles,
            @RequestParam(value = "selected_type", required = false) String userType,
            @RequestParam(value = "datasets", required = false) String dataset,
            @RequestParam(value = "userList", required = false) String datasetUser,
            @RequestParam(value = "manualConfig", required = false) boolean manualConfig,
            HttpSession httpSession,
            HttpServletRequest request);  }### Answer:
@Test public void testLogoutNoSaml() { ModelAndView mav = loginController.logout(null, null, null, httpSession); Mockito.verify(httpSession, Mockito.times(1)).removeAttribute("user_session_key"); assertEquals("loggedOut", mav.getViewName()); }
@Test public void testLogoutWithSaml() { ModelAndView mav = loginController.logout("SAMLRequest", "realm", null, httpSession); assertEquals("You are now logged out", mav.getModel().get("msg")); assertEquals("login", mav.getViewName()); Mockito.verify(httpSession, Mockito.times(1)).removeAttribute("user_session_key"); }