@Test public void testGetUser() { when(request.getUserPrincipal()).thenReturn(null); assertEquals( new UserInfo("Admin Mode", false, LANG), controller.getUser(request) ); when(request.getUserPrincipal()).thenReturn(principal); when(principal.getName()).thenReturn(USER_NAME); assertEquals( new UserInfo(USER_NAME, true, LANG), controller.getUser(request) ); }
@RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody public UserInfo getUser(HttpServletRequest request) { String lang = localeService.getUserLocale(request).getLanguage(); boolean securityLaunch = request.getUserPrincipal() != null; String userName = securityLaunch ? request.getUserPrincipal().getName() : "Admin Mode"; return new UserInfo(userName, securityLaunch, lang); }
DashboardController { @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody public UserInfo getUser(HttpServletRequest request) { String lang = localeService.getUserLocale(request).getLanguage(); boolean securityLaunch = request.getUserPrincipal() != null; String userName = securityLaunch ? request.getUserPrincipal().getName() : "Admin Mode"; return new UserInfo(userName, securityLaunch, lang); } }
DashboardController { @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody public UserInfo getUser(HttpServletRequest request) { String lang = localeService.getUserLocale(request).getLanguage(); boolean securityLaunch = request.getUserPrincipal() != null; String userName = securityLaunch ? request.getUserPrincipal().getName() : "Admin Mode"; return new UserInfo(userName, securityLaunch, lang); }  }
DashboardController { @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody public UserInfo getUser(HttpServletRequest request) { String lang = localeService.getUserLocale(request).getLanguage(); boolean securityLaunch = request.getUserPrincipal() != null; String userName = securityLaunch ? request.getUserPrincipal().getName() : "Admin Mode"; return new UserInfo(userName, securityLaunch, lang); }  @RequestMapping({ "/index", "/", "/home" }) ModelAndView index(final HttpServletRequest request); @RequestMapping(value = "/accessdenied", method = RequestMethod.GET) ModelAndView accessdenied(final HttpServletRequest request); @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody UserInfo getUser(HttpServletRequest request); @RequestMapping(value = "/getStatus", method = RequestMethod.GET) @ResponseBody List<StatusData> getStatus(); boolean isInboundChannelActive(); @Autowired void setStartupManager(StartupManager startupManager); @Autowired void setLocaleService(LocaleService localeService); @Autowired void setEventConsumerInfo(EventConsumerInfo eventConsumerInfo); }
DashboardController { @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody public UserInfo getUser(HttpServletRequest request) { String lang = localeService.getUserLocale(request).getLanguage(); boolean securityLaunch = request.getUserPrincipal() != null; String userName = securityLaunch ? request.getUserPrincipal().getName() : "Admin Mode"; return new UserInfo(userName, securityLaunch, lang); }  @RequestMapping({ "/index", "/", "/home" }) ModelAndView index(final HttpServletRequest request); @RequestMapping(value = "/accessdenied", method = RequestMethod.GET) ModelAndView accessdenied(final HttpServletRequest request); @RequestMapping(value = "/getUser", method = RequestMethod.GET) @ResponseBody UserInfo getUser(HttpServletRequest request); @RequestMapping(value = "/getStatus", method = RequestMethod.GET) @ResponseBody List<StatusData> getStatus(); boolean isInboundChannelActive(); @Autowired void setStartupManager(StartupManager startupManager); @Autowired void setLocaleService(LocaleService localeService); @Autowired void setEventConsumerInfo(EventConsumerInfo eventConsumerInfo);  }