Search in sources :

Example 16 with SystemEntityType

use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.

the class SystemEntityTypeRegistryImplTest method testGetSystemAttributeNotPermitted.

@Test(expectedExceptions = MolgenisDataAccessException.class)
public void testGetSystemAttributeNotPermitted() {
    String entityTypeId = "entityType";
    SystemEntityType systemEntityType = mock(SystemEntityType.class);
    when(systemEntityType.getId()).thenReturn(entityTypeId);
    Attribute attr = when(mock(Attribute.class).getIdentifier()).thenReturn("attr").getMock();
    when(systemEntityType.getAllAttributes()).thenReturn(singletonList(attr));
    when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(false);
    systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
    assertEquals(systemEntityTypeRegistry.getSystemAttribute("attr"), attr);
}
Also used : Attribute(org.molgenis.data.meta.model.Attribute) SystemEntityType(org.molgenis.data.meta.SystemEntityType) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

SystemEntityType (org.molgenis.data.meta.SystemEntityType)16 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)13 Test (org.testng.annotations.Test)13 Attribute (org.molgenis.data.meta.model.Attribute)6 AttributeMetadata (org.molgenis.data.meta.model.AttributeMetadata)2 EntityTypeMetadata (org.molgenis.data.meta.model.EntityTypeMetadata)2 ApplicationContext (org.springframework.context.ApplicationContext)2 SystemPackage (org.molgenis.data.meta.SystemPackage)1 RootSystemPackage (org.molgenis.data.system.model.RootSystemPackage)1 GenericDependencyResolver (org.molgenis.data.util.GenericDependencyResolver)1 BeforeClass (org.testng.annotations.BeforeClass)1