@Test public void shouldAddDocumentationUrls() { setUpRest(); when(userService.getRoles(USERNAME)).thenReturn(Arrays.asList("emailRole", "mcRole")); when(bundle.getHeaders().get(DOC_URL)).thenReturn("www.docs.motechproject.org"); ModuleMenu menu = menuBuilder.buildMenu(USERNAME); assertEquals(menu.getSections().get(0).getModuleDocsUrl(), "www.docs.motechproject.org"); assertNotNull(menu); }
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);  }