use of org.motechproject.server.web.dto.ModuleMenuSection in project motech by motech.
the class MenuBuilderTest method shouldNotAddLinksForSubMenusForWhichUserDoesNotHaveRequisiteRole.
@Test
public void shouldNotAddLinksForSubMenusForWhichUserDoesNotHaveRequisiteRole() {
setUpToTestAccessControlledSubMenuLinks(true);
when(userService.getRoles(USERNAME)).thenReturn(Arrays.asList("fooRole"));
when(bundle.getHeaders().get(DOC_URL)).thenReturn("http://grameenfoundation.org/");
ModuleMenu menu = menuBuilder.buildMenu(USERNAME);
assertNotNull(menu);
List<ModuleMenuSection> menuSections = menu.getSections();
assertNotNull(menuSections);
ModuleMenuLink onlyFooHasAccessToLink = new ModuleMenuLink("Foo", "foo", "#/foo", false, null);
ModuleMenuLink onlyBarHasAccessToLink = new ModuleMenuLink("Bar", "foo", "#/bar", false, null);
ModuleMenuLink linkIsNotAccessControlled = new ModuleMenuLink("Random", "foo", "#/random", false, null);
ModuleMenuSection fooMenuSection = menuSections.get(0);
assertNotNull(fooMenuSection);
assertTrue(fooMenuSection.hasLinkFor(onlyFooHasAccessToLink.getUrl()));
assertTrue(fooMenuSection.hasLinkFor(linkIsNotAccessControlled.getUrl()));
assertFalse(fooMenuSection.hasLinkFor(onlyBarHasAccessToLink.getUrl()));
}
use of org.motechproject.server.web.dto.ModuleMenuSection in project motech by motech.
the class MenuBuilder method serverModulesMenuSection.
private ModuleMenuSection serverModulesMenuSection(List<String> userRoles) {
ModuleMenuSection modulesSection = new ModuleMenuSection("server.modules", false);
for (ModuleRegistrationData moduleRegistrationData : getModulesWithoutSubMenu(userRoles)) {
String name = moduleRegistrationData.getModuleName();
String angularName = getAngularModuleName(moduleRegistrationData);
boolean needsAttention = moduleRegistrationData.isNeedsAttention();
// these menu items don't make use of urls, the name is sufficient
ModuleMenuLink link = new ModuleMenuLink(name, angularName, determineDefaultTab(moduleRegistrationData), needsAttention, moduleRegistrationData.getDocumentationUrl());
modulesSection.addLink(link);
}
return modulesSection;
}
Aggregations