@Test void testGetContext() throws Exception { mockMvc .perform(get("/app-ui-context")) .andExpect(status().isOk()) .andExpect(jsonPath("$.navBarLogo", is(appSettings.getLogoNavBarHref()))) .andExpect(jsonPath("$.logoTop", is(appSettings.getLogoTopHref()))) .andExpect(jsonPath("$.logoTopMaxHeight", is(appSettings.getLogoTopMaxHeight()))) .andExpect(jsonPath("$.loginHref", is(UiContextController.LOGIN_HREF))) .andExpect(jsonPath("$.helpLink.label", is("Help"))) .andExpect(jsonPath("$.helpLink.href", is(UiContextController.HELP_HREF))) .andExpect(jsonPath("$.authenticated", is(true))) .andExpect(jsonPath("$.username", is("henkie"))) .andExpect(jsonPath("$.email", is("henkie@example.org"))) .andExpect(jsonPath("$.roles.length()", is(2))) .andExpect(jsonPath("$.showCookieWall", is(false))) .andExpect(jsonPath("$.menu.id", is("main"))) .andExpect(jsonPath("$.menu.items.length()", is(6))) .andExpect(jsonPath("$.additionalMessage", is("<a class=\"foo\">message</a>"))) .andExpect(jsonPath("$.version", is("mock-version"))) .andExpect(jsonPath("$.buildDate", is("mock date-time"))) .andExpect(jsonPath("$.cssHref", is("cssHref"))) .andExpect( jsonPath("$.selectedTheme", is("/css/bootstrap-4/selected-theme.css?fingerprint"))); }
@GetMapping("/**") @ResponseBody public UiContextResponse getContext() { User user = userAccountService.getCurrentUser(); return UiContextResponse.builder() .setMenu(menuReaderService.getMenu().orElse(null)) .setSelectedTheme(buildSelectedThemeURL()) .setCssHref(appSettings.getCssHref()) .setNavBarLogo(appSettings.getLogoNavBarHref()) .setLogoTop(appSettings.getLogoTopHref()) .setLogoTopMaxHeight(appSettings.getLogoTopMaxHeight()) .setLoginHref(LOGIN_HREF) .setHelpLink(ImmutableMap.of("label", "Help", "href", HELP_HREF)) .setShowCookieWall(cookieWallService.showCookieWall()) .setAuthenticated(currentUserIsAuthenticated()) .setUsername(user.getUsername()) .setEmail(user.getEmail()) .setRoles(getCurrentUserRoles()) .setAdditionalMessage(appSettings.getFooter()) .setVersion(this.molgenisVersion) .setBuildDate(this.molgenisBuildDate) .build(); }
UiContextController { @GetMapping("/**") @ResponseBody public UiContextResponse getContext() { User user = userAccountService.getCurrentUser(); return UiContextResponse.builder() .setMenu(menuReaderService.getMenu().orElse(null)) .setSelectedTheme(buildSelectedThemeURL()) .setCssHref(appSettings.getCssHref()) .setNavBarLogo(appSettings.getLogoNavBarHref()) .setLogoTop(appSettings.getLogoTopHref()) .setLogoTopMaxHeight(appSettings.getLogoTopMaxHeight()) .setLoginHref(LOGIN_HREF) .setHelpLink(ImmutableMap.of("label", "Help", "href", HELP_HREF)) .setShowCookieWall(cookieWallService.showCookieWall()) .setAuthenticated(currentUserIsAuthenticated()) .setUsername(user.getUsername()) .setEmail(user.getEmail()) .setRoles(getCurrentUserRoles()) .setAdditionalMessage(appSettings.getFooter()) .setVersion(this.molgenisVersion) .setBuildDate(this.molgenisBuildDate) .build(); } }
UiContextController { @GetMapping("/**") @ResponseBody public UiContextResponse getContext() { User user = userAccountService.getCurrentUser(); return UiContextResponse.builder() .setMenu(menuReaderService.getMenu().orElse(null)) .setSelectedTheme(buildSelectedThemeURL()) .setCssHref(appSettings.getCssHref()) .setNavBarLogo(appSettings.getLogoNavBarHref()) .setLogoTop(appSettings.getLogoTopHref()) .setLogoTopMaxHeight(appSettings.getLogoTopMaxHeight()) .setLoginHref(LOGIN_HREF) .setHelpLink(ImmutableMap.of("label", "Help", "href", HELP_HREF)) .setShowCookieWall(cookieWallService.showCookieWall()) .setAuthenticated(currentUserIsAuthenticated()) .setUsername(user.getUsername()) .setEmail(user.getEmail()) .setRoles(getCurrentUserRoles()) .setAdditionalMessage(appSettings.getFooter()) .setVersion(this.molgenisVersion) .setBuildDate(this.molgenisBuildDate) .build(); } UiContextController(
      AppSettings appSettings,
      CookieWallService cookieWallService,
      MenuReaderService menuReaderService,
      UserAccountService userAccountService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildDate,
      ThemeFingerprintRegistry themeFingerprintRegistry); }
UiContextController { @GetMapping("/**") @ResponseBody public UiContextResponse getContext() { User user = userAccountService.getCurrentUser(); return UiContextResponse.builder() .setMenu(menuReaderService.getMenu().orElse(null)) .setSelectedTheme(buildSelectedThemeURL()) .setCssHref(appSettings.getCssHref()) .setNavBarLogo(appSettings.getLogoNavBarHref()) .setLogoTop(appSettings.getLogoTopHref()) .setLogoTopMaxHeight(appSettings.getLogoTopMaxHeight()) .setLoginHref(LOGIN_HREF) .setHelpLink(ImmutableMap.of("label", "Help", "href", HELP_HREF)) .setShowCookieWall(cookieWallService.showCookieWall()) .setAuthenticated(currentUserIsAuthenticated()) .setUsername(user.getUsername()) .setEmail(user.getEmail()) .setRoles(getCurrentUserRoles()) .setAdditionalMessage(appSettings.getFooter()) .setVersion(this.molgenisVersion) .setBuildDate(this.molgenisBuildDate) .build(); } UiContextController(
      AppSettings appSettings,
      CookieWallService cookieWallService,
      MenuReaderService menuReaderService,
      UserAccountService userAccountService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildDate,
      ThemeFingerprintRegistry themeFingerprintRegistry); @GetMapping("/**") @ResponseBody UiContextResponse getContext(); }
UiContextController { @GetMapping("/**") @ResponseBody public UiContextResponse getContext() { User user = userAccountService.getCurrentUser(); return UiContextResponse.builder() .setMenu(menuReaderService.getMenu().orElse(null)) .setSelectedTheme(buildSelectedThemeURL()) .setCssHref(appSettings.getCssHref()) .setNavBarLogo(appSettings.getLogoNavBarHref()) .setLogoTop(appSettings.getLogoTopHref()) .setLogoTopMaxHeight(appSettings.getLogoTopMaxHeight()) .setLoginHref(LOGIN_HREF) .setHelpLink(ImmutableMap.of("label", "Help", "href", HELP_HREF)) .setShowCookieWall(cookieWallService.showCookieWall()) .setAuthenticated(currentUserIsAuthenticated()) .setUsername(user.getUsername()) .setEmail(user.getEmail()) .setRoles(getCurrentUserRoles()) .setAdditionalMessage(appSettings.getFooter()) .setVersion(this.molgenisVersion) .setBuildDate(this.molgenisBuildDate) .build(); } UiContextController(
      AppSettings appSettings,
      CookieWallService cookieWallService,
      MenuReaderService menuReaderService,
      UserAccountService userAccountService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildDate,
      ThemeFingerprintRegistry themeFingerprintRegistry); @GetMapping("/**") @ResponseBody UiContextResponse getContext(); static final String ID; static final String LOGIN_HREF; static final String HELP_HREF; }