@Test void testForwardSpecificMenuDoesNotExist() { when(menuReaderService.getMenu()).thenReturn(Optional.of(menu)); assertThrows( RuntimeException.class, () -> molgenisMenuController.forwardMenuDefaultPlugin("nonexisting", model)); }
@SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") public String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model) { Menu filteredMenu = menuReaderService .getMenu() .flatMap(menu -> menu.findMenu(menuId)) .orElseThrow( () -> new RuntimeException("menu with id [" + menuId + "] does not exist")); model.addAttribute(KEY_MENU_ID, menuId); String pluginId = filteredMenu.firstItem().map(MenuItem::getId).orElse(VoidPluginController.ID); String contextUri = URI + '/' + menuId + '/' + pluginId; addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId); }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") public String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model) { Menu filteredMenu = menuReaderService .getMenu() .flatMap(menu -> menu.findMenu(menuId)) .orElseThrow( () -> new RuntimeException("menu with id [" + menuId + "] does not exist")); model.addAttribute(KEY_MENU_ID, menuId); String pluginId = filteredMenu.firstItem().map(MenuItem::getId).orElse(VoidPluginController.ID); String contextUri = URI + '/' + menuId + '/' + pluginId; addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId); } }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") public String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model) { Menu filteredMenu = menuReaderService .getMenu() .flatMap(menu -> menu.findMenu(menuId)) .orElseThrow( () -> new RuntimeException("menu with id [" + menuId + "] does not exist")); model.addAttribute(KEY_MENU_ID, menuId); String pluginId = filteredMenu.firstItem().map(MenuItem::getId).orElse(VoidPluginController.ID); String contextUri = URI + '/' + menuId + '/' + pluginId; addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId); } MolgenisMenuController(
      MenuReaderService menuReaderService,
      @Value("${molgenis.version}") String molgenisVersion,
      @Value("${molgenis.build.date}") String molgenisBuildData,
      DataService dataService); }
MolgenisMenuController { @SuppressWarnings("java:S3752") @RequestMapping( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") public String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model) { Menu filteredMenu = menuReaderService .getMenu() .flatMap(menu -> menu.findMenu(menuId)) .orElseThrow( () -> new RuntimeException("menu with id [" + menuId + "] does not exist")); model.addAttribute(KEY_MENU_ID, menuId); String pluginId = filteredMenu.firstItem().map(MenuItem::getId).orElse(VoidPluginController.ID); String contextUri = URI + '/' + menuId + '/' + pluginId; addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId); } 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( method = {RequestMethod.GET, RequestMethod.POST}, value = "/{menuId}") public String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model) { Menu filteredMenu = menuReaderService .getMenu() .flatMap(menu -> menu.findMenu(menuId)) .orElseThrow( () -> new RuntimeException("menu with id [" + menuId + "] does not exist")); model.addAttribute(KEY_MENU_ID, menuId); String pluginId = filteredMenu.firstItem().map(MenuItem::getId).orElse(VoidPluginController.ID); String contextUri = URI + '/' + menuId + '/' + pluginId; addModelAttributes(model, contextUri); return getForwardPluginUri(pluginId); } 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; }