@Test public void shouldBuildMenuWithAllLinks() { setUpRest(); when(userService.getRoles(USERNAME)).thenReturn(Arrays.asList("emailRole", "adminRole", "schedulerRole", "mcRole", "mdsRole", "viewRestRole")); when(dictionary.get(DOC_URL)).thenReturn("http: ModuleMenu menu = menuBuilder.buildMenu(USERNAME); assertNotNull(menu); List<ModuleMenuSection> menuSections = menu.getSections(); assertNotNull(menuSections); assertEquals(4, menuSections.size()); ModuleMenuSection adminSection = menu.getSections().get(0); verifyAdminSection(adminSection); ModuleMenuSection wsSection = menu.getSections().get(1); verifyWsSection(wsSection); ModuleMenuSection modulesSection = menu.getSections().get(2); verifyModulesSection(modulesSection, true, true); ModuleMenuSection restSection = menu.getSections().get(3); verifyRestSection(restSection, true, true); }
public ModuleMenu buildMenu(String username) { ModuleMenu moduleMenu = new ModuleMenu(); List<String> userRoles = userService.getRoles(username); for (ModuleRegistrationData moduleRegistrationData : getModulesWithSubMenu(userRoles)) { ModuleMenuSection menuSection = getModuleMenuSection(username, userRoles, moduleRegistrationData); if (!menuSection.getLinks().isEmpty()) { moduleMenu.addMenuSection(menuSection); } } moduleMenu.addMenuSection(serverModulesMenuSection(userRoles)); if (checkUserPermission(userRoles, REST_API_PERMISSION)) { ModuleMenuSection restSection = restDocumentationMenu(); if (CollectionUtils.isNotEmpty(restSection.getLinks())) { moduleMenu.addMenuSection(restSection); } } return moduleMenu; }
MenuBuilder { public ModuleMenu buildMenu(String username) { ModuleMenu moduleMenu = new ModuleMenu(); List<String> userRoles = userService.getRoles(username); for (ModuleRegistrationData moduleRegistrationData : getModulesWithSubMenu(userRoles)) { ModuleMenuSection menuSection = getModuleMenuSection(username, userRoles, moduleRegistrationData); if (!menuSection.getLinks().isEmpty()) { moduleMenu.addMenuSection(menuSection); } } moduleMenu.addMenuSection(serverModulesMenuSection(userRoles)); if (checkUserPermission(userRoles, REST_API_PERMISSION)) { ModuleMenuSection restSection = restDocumentationMenu(); if (CollectionUtils.isNotEmpty(restSection.getLinks())) { moduleMenu.addMenuSection(restSection); } } return moduleMenu; } }
MenuBuilder { public ModuleMenu buildMenu(String username) { ModuleMenu moduleMenu = new ModuleMenu(); List<String> userRoles = userService.getRoles(username); for (ModuleRegistrationData moduleRegistrationData : getModulesWithSubMenu(userRoles)) { ModuleMenuSection menuSection = getModuleMenuSection(username, userRoles, moduleRegistrationData); if (!menuSection.getLinks().isEmpty()) { moduleMenu.addMenuSection(menuSection); } } moduleMenu.addMenuSection(serverModulesMenuSection(userRoles)); if (checkUserPermission(userRoles, REST_API_PERMISSION)) { ModuleMenuSection restSection = restDocumentationMenu(); if (CollectionUtils.isNotEmpty(restSection.getLinks())) { moduleMenu.addMenuSection(restSection); } } return moduleMenu; }  }
MenuBuilder { public ModuleMenu buildMenu(String username) { ModuleMenu moduleMenu = new ModuleMenu(); List<String> userRoles = userService.getRoles(username); for (ModuleRegistrationData moduleRegistrationData : getModulesWithSubMenu(userRoles)) { ModuleMenuSection menuSection = getModuleMenuSection(username, userRoles, moduleRegistrationData); if (!menuSection.getLinks().isEmpty()) { moduleMenu.addMenuSection(menuSection); } } moduleMenu.addMenuSection(serverModulesMenuSection(userRoles)); if (checkUserPermission(userRoles, REST_API_PERMISSION)) { ModuleMenuSection restSection = restDocumentationMenu(); if (CollectionUtils.isNotEmpty(restSection.getLinks())) { moduleMenu.addMenuSection(restSection); } } return moduleMenu; }  ModuleMenu buildMenu(String username); }
MenuBuilder { public ModuleMenu buildMenu(String username) { ModuleMenu moduleMenu = new ModuleMenu(); List<String> userRoles = userService.getRoles(username); for (ModuleRegistrationData moduleRegistrationData : getModulesWithSubMenu(userRoles)) { ModuleMenuSection menuSection = getModuleMenuSection(username, userRoles, moduleRegistrationData); if (!menuSection.getLinks().isEmpty()) { moduleMenu.addMenuSection(menuSection); } } moduleMenu.addMenuSection(serverModulesMenuSection(userRoles)); if (checkUserPermission(userRoles, REST_API_PERMISSION)) { ModuleMenuSection restSection = restDocumentationMenu(); if (CollectionUtils.isNotEmpty(restSection.getLinks())) { moduleMenu.addMenuSection(restSection); } } return moduleMenu; }  ModuleMenu buildMenu(String username);  }