use of org.motechproject.server.web.dto.ModuleMenu in project motech by motech.
the class MenuBuilderTest method shouldBuildMenuWithAllLinks.
@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://grameenfoundation.org/");
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);
}
use of org.motechproject.server.web.dto.ModuleMenu 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()));
}
Aggregations