HomeController implements ControllerConstants { @GetMapping({"/home", "/"}) public String home(User user, @RequestParam(value = "exception", defaultValue = "") String exception, @RequestParam(value = "region", defaultValue = "") String region, ModelMap model, HttpServletResponse response, HttpServletRequest request) { try { Role role; try { recordReferrer(region); setLanguage(userContext.getCurrentUser().getUserLanguage(), response, request); role = user.getRole(); } catch (AuthenticationCredentialsNotFoundException e) { return "app"; } model.addAttribute("handlers", scriptHandlerFactory.getVisibleHandlers()); if (StringUtils.isNotBlank(exception)) { model.addAttribute("exception", exception); } if (role == Role.ADMIN || role == Role.SUPER_USER || role == Role.USER) { return "app"; } else { log.info("Invalid user role:{}", role.getFullName()); return "app"; } } catch (Exception e) { model.addAttribute("exception", e.getMessage()); return "app"; } }  @GetMapping({"/home", "/"}) String home(User user, @RequestParam(value = "exception", defaultValue = "") String exception,
					   @RequestParam(value = "region", defaultValue = "") String region, ModelMap model,
					   HttpServletResponse response, HttpServletRequest request); @GetMapping("/login") String login(ModelMap model);  }
@Test public void testHome() { MockHttpServletResponse res = new MockHttpServletResponse(); MockHttpServletRequest req = new MockHttpServletRequest(); CookieLocaleResolver localeResolver = new CookieLocaleResolver(); req.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, localeResolver); User testUser2 = getTestUser(); testUser2.setUserLanguage("EN"); ModelMap model = new ModelMap(); String viewName = homeController.home(testUser2, null, null, model, res, req); assertThat(viewName, is("app")); User testUserError = Mockito.spy(testUser2); Mockito.when(testUserError.getRole()).thenReturn(Role.SYSTEM_USER); viewName = homeController.home(testUserError, "Test Error message!", null, model, res, req); assertThat(viewName, is("app")); }