### Question:
UserInfoAPIController { @RequestMapping(method = RequestMethod.GET, value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody AcmUserInfoDTO info(Authentication auth, HttpSession session) { log.debug("Getting info for user {}", auth.getName()); List<String> authorities = auth.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList()); AcmUser user = (AcmUser) session.getAttribute("acm_user"); Map<String, Boolean> privilegeMap = (Map<String, Boolean>) session.getAttribute("acm_privileges"); Set<String> privileges = privilegeMap.keySet(); String notificationMessage = (String) session.getAttribute("acm_user_message"); AcmUserInfoDTO retval = new AcmUserInfoDTO(); retval.setUserId(auth.getName()); retval.setFullName(user.getFullName()); retval.setAuthorities(authorities); retval.setPrivileges(privileges); retval.setFirstName(user.getFirstName()); retval.setLastName(user.getLastName()); retval.setMail(user.getMail()); retval.setDirectoryName(user.getUserDirectoryName()); retval.setCountry(user.getCountry()); retval.setCountryAbbreviation(user.getCountryAbbreviation()); retval.setDepartment(user.getDepartment()); retval.setCompany(user.getCompany()); retval.setTitle(user.getTitle()); retval.setNotificationMessage(notificationMessage); retval.setLangCode(user.getLang()); return retval; }  @RequestMapping(method = RequestMethod.GET, value = "/info", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody AcmUserInfoDTO info(Authentication auth, HttpSession session); @RequestMapping(value = "/lang/{lang}", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE) @ResponseBody String updateLang(@PathVariable("lang") String lang, Authentication authentication, HttpSession session); UserDao getUserDao(); void setUserDao(UserDao userDao);  }### Answer:
@Test public void getUserInfo_test() throws Exception { String privilege = "privilege"; Map<String, Boolean> privilegeMap = new HashMap<>(); privilegeMap.put(privilege, Boolean.TRUE); List<GrantedAuthority> grantedAuthorities = new ArrayList<>( Arrays.asList((GrantedAuthority) () -> "INVESTIGATOR", (GrantedAuthority) () -> "ADMINISTRATOR")); AcmUser acmUser = new AcmUser(); acmUser.setUserId("user"); acmUser.setLang("en"); mockSession.setAttribute("acm_user", acmUser); mockSession.setAttribute("acm_privileges", privilegeMap); expect((List<GrantedAuthority>) mockAuthentication.getAuthorities()).andReturn(grantedAuthorities).atLeastOnce(); expect(mockAuthentication.getName()).andReturn("USER").anyTimes(); replayAll(); MvcResult result = mockMvc.perform(get("/api/latest/users/info").accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .principal(mockAuthentication).session(mockSession).contentType(MediaType.APPLICATION_JSON)).andReturn(); verifyAll(); String json = result.getResponse().getContentAsString(); log.info("results: " + result.getResponse().getContentAsString()); assertEquals(HttpStatus.SC_OK, result.getResponse().getStatus()); ObjectMapper objectMapper = new ObjectMapper(); AcmUserInfoDTO retval = objectMapper.readValue(json, AcmUserInfoDTO.class); assertNotNull(retval.getUserId()); assertNotNull(retval.getUserId(), "user"); assertNotNull(retval.getPrivileges()); assertEquals(retval.getPrivileges().size(), 1); assertNotNull(retval.getAuthorities()); assertEquals(retval.getAuthorities().size(), 2); assertEquals(retval.getLangCode(), "en"); }