use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class NegotiatorControllerTest method testShowButton.
@Test
public void testShowButton() {
when(permissionService.hasPermission(new PluginIdentity("directory"), PluginPermission.READ)).thenReturn(true);
assertTrue(negotiatorController.showDirectoryButton("molgenis_id_1"));
}
use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class NegotiatorControllerTest method testShowButtonPermissionsOnPluginNoConfig.
@Test
public void testShowButtonPermissionsOnPluginNoConfig() {
when(permissionService.hasPermission(new PluginIdentity("directory"), PluginPermission.READ)).thenReturn(false);
when(entityType.getId()).thenReturn("blah2");
assertFalse(negotiatorController.showDirectoryButton("blah2"));
}
use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class UserPermissionEvaluatorImplTest method hasPermissionOnPluginTrue.
@WithMockUser(username = "USER")
@Test
public void hasPermissionOnPluginTrue() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
when(permissionEvaluator.hasPermission(authentication, "plugin1", "plugin", PluginPermission.READ)).thenReturn(true);
assertTrue(userPermissionEvaluator.hasPermission(new PluginIdentity("plugin1"), PluginPermission.READ));
}
use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class XmlMolgenisUiMenuTest method getActiveItem_noActiveItem.
@Test
public void getActiveItem_noActiveItem() {
String menuId = "menuId";
MenuType menuType = new MenuType();
menuType.setName(menuId);
PluginType plugin1Type = new PluginType();
plugin1Type.setId("plugin1");
plugin1Type.setName("plugin1");
PluginType plugin3Type = new PluginType();
plugin3Type.setId("plugin3");
plugin3Type.setName("plugin3");
MenuType menu1Type = new MenuType();
menu1Type.setName("menu1");
menu1Type.getMenuOrPlugin().add(plugin3Type);
menuType.getMenuOrPlugin().add(plugin1Type);
menuType.getMenuOrPlugin().add(menu1Type);
when(permissionService.hasPermission(new PluginIdentity("plugin1"), PluginPermission.READ)).thenReturn(false);
when(permissionService.hasPermission(new PluginIdentity("plugin3"), PluginPermission.READ)).thenReturn(true);
XmlMolgenisUiMenu xmlMolgenisUiMenu = new XmlMolgenisUiMenu(menuType, permissionService);
assertNull(xmlMolgenisUiMenu.getActiveItem());
}
use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class XmlMolgenisUiMenuTest method getItems.
@Test
public void getItems() {
String menuId = "menuId";
MenuType menuType = new MenuType();
menuType.setName(menuId);
PluginType plugin1Type = new PluginType();
plugin1Type.setId("plugin1");
plugin1Type.setName("plugin1");
PluginType plugin2Type = new PluginType();
plugin2Type.setId("plugin2");
plugin2Type.setName("plugin2");
PluginType plugin3Type = new PluginType();
plugin3Type.setId("plugin3");
plugin3Type.setName("plugin3");
MenuType menu1Type = new MenuType();
menu1Type.setName("menu1");
menu1Type.getMenuOrPlugin().add(plugin3Type);
menuType.getMenuOrPlugin().add(plugin1Type);
menuType.getMenuOrPlugin().add(plugin2Type);
menuType.getMenuOrPlugin().add(menu1Type);
when(permissionService.hasPermission(new PluginIdentity("plugin1"), PluginPermission.READ)).thenReturn(true);
when(permissionService.hasPermission(new PluginIdentity("plugin2"), PluginPermission.READ)).thenReturn(false);
when(permissionService.hasPermission(new PluginIdentity("plugin3"), PluginPermission.READ)).thenReturn(true);
XmlMolgenisUiMenu xmlMolgenisUiMenu = new XmlMolgenisUiMenu(menuType, permissionService);
Iterator<UiMenuItem> it = xmlMolgenisUiMenu.getItems().iterator();
assertTrue(it.hasNext());
assertEquals(it.next().getName(), "plugin1");
assertEquals(it.next().getName(), "menu1");
}
Aggregations