### Question:
HomeController extends AbstractController { @GetMapping(path = "/logout") public String logout(Principal principal, HttpServletRequest request) throws ServletException { if (principal != null) { profileService.logout(principal); } request.logout(); return "redirect:/"; } HomeController(ProfileService profileService,
                          ApplicationEventPublisher eventPublisher,
                          final RequestService requestService,
                          final ObjectMapper objectMapper,
                          final Mappers mappers); @RequestMapping("/") ModelAndView home(@RequestParam(value = "ref", required = false) String ref, RedirectAttributes redirectAttributes, Principal principal); @GetMapping(value = {"/requestsActiveCount"}, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody String getRequestsActiveCount(Principal principal); @RequestMapping("/user/login") ModelAndView login(RedirectAttributes redirectAttributes, HttpServletRequest request); @GetMapping(path = "/logout") String logout(Principal principal, HttpServletRequest request);  }### Answer:
@Test public void logoutWithPrincipal() throws Exception { Principal principal = PrincipalMother.davyvanroy(); mockMvc.perform(get("/logout").principal(principal)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("/")); verify(profileService).logout(principal); }