### Question:
SSOController { @RequestMapping(value = "/discovery", method = RequestMethod.GET) public String idpSelection(HttpServletRequest request, Model model) { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth == null) LOG.debug("Current authentication instance from security context is null"); else LOG.debug("Current authentication instance from security context: " + this.getClass().getSimpleName()); if (auth == null || (auth instanceof AnonymousAuthenticationToken)) { Set<String> idps = metadata.getIDPEntityNames(); for (String idp : idps) LOG.info("Configured Identity Provider for SSO: " + idp); model.addAttribute("idps", idps); return "pages/discovery"; } else { LOG.warn("The current user is already logged."); return "redirect:/landing"; } }  @RequestMapping(value = "/discovery", method = RequestMethod.GET) String idpSelection(HttpServletRequest request, Model model);  }### Answer:
@Test public void testIdpSelection() throws Exception { when(metadata.getIDPEntityNames()).thenReturn(IDPS); mockMvc.perform(get("/saml/discovery").session(mockAnonymousHttpSession())) .andExpect(status().isOk()) .andExpect(model().attribute("idps", IDPS)) .andExpect(view().name("pages/discovery")); }