use of org.motechproject.osgi.web.util.ModuleRegistrations in project motech by motech.
the class MenuBuilderTest method setUpMenu.
private void setUpMenu() {
HashMap<String, String> i18n = new HashMap<>();
List<String> angularModules = new ArrayList<>();
ModuleRegistrationData adminRegData = new ModuleRegistrationData("admin", "/admin", angularModules, i18n);
adminRegData.setRoleForAccess("adminPerm");
adminRegData.addSubMenu("#/log", "Log");
adminRegData.addSubMenu("#/settings", "Settings");
adminRegData.addSubMenu("#/manage", "manage.modules");
adminRegData.setNeedsAttention(true);
adminRegData.addAngularModule("admin");
adminRegData.setBundle(bundle);
ModuleRegistrationData wsRegData = new ModuleRegistrationData("web-security", "/ws", angularModules, i18n);
wsRegData.addSubMenu("#/roles", "Roles");
wsRegData.addSubMenu("#/users", "Users");
wsRegData.addAngularModule("webSecurity");
wsRegData.setBundle(bundle);
ModuleRegistrationData emailRegData = new ModuleRegistrationData("email", "/email", angularModules, i18n);
List<String> rolesForAccess = new ArrayList<>();
rolesForAccess.add("emailPerm");
rolesForAccess.add("otherPerm");
rolesForAccess.add("completlyOtherPerm");
emailRegData.setRoleForAccess(rolesForAccess);
emailRegData.addAngularModule("email");
emailRegData.setDefaultURL("/email/send");
emailRegData.setBundle(bundle);
ModuleRegistrationData schedulerRegData = new ModuleRegistrationData("scheduler", "/scheduler", angularModules, i18n);
schedulerRegData.setRoleForAccess("schedulerPerm");
schedulerRegData.setDefaultURL("/scheduler");
schedulerRegData.setBundle(bundle);
ModuleRegistrationData metricsRegData = new ModuleRegistrationData("metrics", "/metrics", angularModules, i18n);
metricsRegData.setDefaultURL("/metrics");
metricsRegData.setBundle(bundle);
ModuleRegistrationData outboxRegData = new ModuleRegistrationData("outbox", "outbox", null, i18n);
outboxRegData.setBundle(bundle);
ModuleRegistrations modules = new ModuleRegistrations();
modules.setModulesWithoutSubmenu(Arrays.asList(emailRegData, schedulerRegData, metricsRegData));
modules.setModulesWithSubMenu(Arrays.asList(adminRegData, wsRegData));
modules.setModulesWithoutUI(Arrays.asList(outboxRegData));
when(uiFrameworkService.getRegisteredModules()).thenReturn(modules);
}
use of org.motechproject.osgi.web.util.ModuleRegistrations in project motech by motech.
the class UIFrameworkServiceImplTest method testRegisterUnregisterModule.
@Test
public void testRegisterUnregisterModule() {
// register
service.registerModule(moduleRegistration);
ModuleRegistrations result = service.getRegisteredModules();
assertTrue(result.getModulesWithSubMenu().isEmpty());
assertTrue(result.getModulesWithoutSubmenu().contains(moduleRegistration));
// unregister
service.unregisterModule(moduleRegistration.getModuleName());
result = service.getRegisteredModules();
assertTrue(result.getModulesWithSubMenu().isEmpty());
assertTrue(result.getModulesWithSubMenu().isEmpty());
}
use of org.motechproject.osgi.web.util.ModuleRegistrations in project motech by motech.
the class MenuBuilderTest method setUpToTestAccessControlledSubMenuLinks.
private void setUpToTestAccessControlledSubMenuLinks(boolean addSubMenuWithoutAccessControl) {
ModuleRegistrationData fooRegData = new ModuleRegistrationData("foo", "foo");
Map<String, SubmenuInfo> subMenuMap = new HashMap<>();
SubmenuInfo subMenuWithAccessForUserFoo = new SubmenuInfo("#/foo");
subMenuWithAccessForUserFoo.setRoleForAccess("foo");
SubmenuInfo subMenuWithAccessForUserBar = new SubmenuInfo("#/bar");
subMenuWithAccessForUserBar.setRoleForAccess("bar");
SubmenuInfo subMenuWithoutAccessControl = new SubmenuInfo("#/random");
subMenuMap.put("Foo", subMenuWithAccessForUserFoo);
subMenuMap.put("Bar", subMenuWithAccessForUserBar);
if (addSubMenuWithoutAccessControl) {
subMenuMap.put("Random", subMenuWithoutAccessControl);
}
fooRegData.setSubMenu(subMenuMap);
fooRegData.setBundle(bundle);
ModuleRegistrations modules = new ModuleRegistrations();
modules.setModulesWithSubMenu(Arrays.asList(fooRegData));
when(uiFrameworkService.getRegisteredModules()).thenReturn(modules);
RoleDto fooRole = new RoleDto("fooRole", Arrays.asList("foo"));
RoleDto someOtherRole = new RoleDto("someOtherRole", Arrays.asList("someOtherPermission"));
when(roleService.getRole("fooRole")).thenReturn(fooRole);
when(roleService.getRole("someOtherRole")).thenReturn(someOtherRole);
}
Aggregations