@Test void testForwardSpecificMenuSpecificPluginDoesNotCheckMenu() { when(dataService.findOneById(PLUGIN, "permissions", Plugin.class)).thenReturn(plugin); when(plugin.getPath()).thenReturn("permissions"); when(request.getAttribute(PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)) .thenReturn("/menu/admin/permissions/blah/blah?x=y&a=b"); assertEquals( "forward:/plugin/permissions molgenisMenuController.forwardMenuPlugin(request, "admin", "permissions", model)); verify(model).addAttribute("menu_id", "admin"); verify(model).addAttribute("context_url", "/menu/admin/permissions"); verify(model).addAttribute("molgenis_version", "1.2.3"); verify(model).addAttribute("molgenis_build_date", "2019-01-02 01:11 UTC"); verifyNoMoreInteractions(model); }
@SuppressWarnings("java:S3752") @RequestMapping("/{menuId}/{pluginId}/**") public String forwardMenuPlugin( HttpServletRequest request, @Valid @NotNull @PathVariable String menuId, @Valid @NotNull @PathVariable String pluginId, Model model) { String contextUri = URI + '/' + menuId + '/' + pluginId; String mappingUri = (String) (request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)); String remainder = mappingUri.substring(contextUri.length()); model.addAttribute(KEY_MENU_ID, menuId); addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId, remainder); }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping("/{menuId}/{pluginId}/**") public String forwardMenuPlugin( HttpServletRequest request, @Valid @NotNull @PathVariable String menuId, @Valid @NotNull @PathVariable String pluginId, Model model) { String contextUri = URI + '/' + menuId + '/' + pluginId; String mappingUri = (String) (request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)); String remainder = mappingUri.substring(contextUri.length()); model.addAttribute(KEY_MENU_ID, menuId); addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId, remainder); } }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping("/{menuId}/{pluginId}/**") public String forwardMenuPlugin( HttpServletRequest request, @Valid @NotNull @PathVariable String menuId, @Valid @NotNull @PathVariable String pluginId, Model model) { String contextUri = URI + '/' + menuId + '/' + pluginId; String mappingUri = (String) (request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)); String remainder = mappingUri.substring(contextUri.length()); model.addAttribute(KEY_MENU_ID, menuId); addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId, remainder); } MolgenisMenuController(
      MenuReaderService menuReaderService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildData,
      DataService dataService); }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping("/{menuId}/{pluginId}/**") public String forwardMenuPlugin( HttpServletRequest request, @Valid @NotNull @PathVariable String menuId, @Valid @NotNull @PathVariable String pluginId, Model model) { String contextUri = URI + '/' + menuId + '/' + pluginId; String mappingUri = (String) (request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)); String remainder = mappingUri.substring(contextUri.length()); model.addAttribute(KEY_MENU_ID, menuId); addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId, remainder); } MolgenisMenuController(
      MenuReaderService menuReaderService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildData,
      DataService dataService); @Transactional(readOnly = true) @SuppressWarnings("java:S3752") // multiple methods required @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}) String forwardDefaultMenuDefaultPlugin(Model model); @SuppressWarnings("java:S3752") // multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model); @SuppressWarnings("java:S3752") // multiple methods required @RequestMapping("/{menuId}/{pluginId}/**") String forwardMenuPlugin(
      HttpServletRequest request,
      @Valid @NotNull @PathVariable String menuId,
      @Valid @NotNull @PathVariable String pluginId,
      Model model); }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping("/{menuId}/{pluginId}/**") public String forwardMenuPlugin( HttpServletRequest request, @Valid @NotNull @PathVariable String menuId, @Valid @NotNull @PathVariable String pluginId, Model model) { String contextUri = URI + '/' + menuId + '/' + pluginId; String mappingUri = (String) (request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)); String remainder = mappingUri.substring(contextUri.length()); model.addAttribute(KEY_MENU_ID, menuId); addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId, remainder); } MolgenisMenuController(
      MenuReaderService menuReaderService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildData,
      DataService dataService); @Transactional(readOnly = true) @SuppressWarnings("java:S3752") // multiple methods required @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}) String forwardDefaultMenuDefaultPlugin(Model model); @SuppressWarnings("java:S3752") // multiple methods required @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model); @SuppressWarnings("java:S3752") // multiple methods required @RequestMapping("/{menuId}/{pluginId}/**") String forwardMenuPlugin(
      HttpServletRequest request,
      @Valid @NotNull @PathVariable String menuId,
      @Valid @NotNull @PathVariable String pluginId,
      Model model); static final String URI; }