@Test public void getLoggedInUser_UserIsNotLoggedIn_ShouldReturnNull() { when(securityContextUtilMock.getPrincipal()).thenReturn(null); UserDTO loggedInUser = controller.getLoggedInUser(); verify(securityContextUtilMock, times(1)).getPrincipal(); verifyNoMoreInteractions(securityContextUtilMock); assertNull(loggedInUser); }
@RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody public UserDTO getLoggedInUser() { LOGGER.debug("Getting logged in user."); UserDetails principal = securityContextUtil.getPrincipal(); return createDTO(principal); }
UserController { @RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody public UserDTO getLoggedInUser() { LOGGER.debug("Getting logged in user."); UserDetails principal = securityContextUtil.getPrincipal(); return createDTO(principal); } }
UserController { @RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody public UserDTO getLoggedInUser() { LOGGER.debug("Getting logged in user."); UserDetails principal = securityContextUtil.getPrincipal(); return createDTO(principal); }  }
UserController { @RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody public UserDTO getLoggedInUser() { LOGGER.debug("Getting logged in user."); UserDetails principal = securityContextUtil.getPrincipal(); return createDTO(principal); }  @RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody UserDTO getLoggedInUser(); }
UserController { @RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody public UserDTO getLoggedInUser() { LOGGER.debug("Getting logged in user."); UserDetails principal = securityContextUtil.getPrincipal(); return createDTO(principal); }  @RequestMapping(value = "/api/user", method = RequestMethod.GET) @ResponseBody UserDTO getLoggedInUser();  }