use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testGetSystemEntityTypeNotPermitted.
@Test(expectedExceptions = MolgenisDataAccessException.class)
public void testGetSystemEntityTypeNotPermitted() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(false);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
systemEntityTypeRegistry.getSystemEntityType(entityTypeId);
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testGetSystemAttributeCompoundNotExists.
@Test
public void testGetSystemAttributeCompoundNotExists() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
Attribute attr = when(mock(Attribute.class).getIdentifier()).thenReturn("attr").getMock();
when(attr.getDataType()).thenReturn(AttributeType.STRING);
Attribute compoundAttr = when(mock(Attribute.class).getIdentifier()).thenReturn("compoundAttr").getMock();
when(compoundAttr.getDataType()).thenReturn(AttributeType.COMPOUND);
when(compoundAttr.getChildren()).thenReturn(singletonList(attr));
when(systemEntityType.getAllAttributes()).thenReturn(singletonList(compoundAttr));
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(true);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
assertNull(systemEntityTypeRegistry.getSystemAttribute("unknownAttr"));
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class AbstractMolgenisSpringTest method abstractMolgenisSpringTestBeforeClass.
// long method name, because if a method annotated with @BeforeClass and the same method name exists in a subclass then this method is ignored.
@BeforeClass
public void abstractMolgenisSpringTestBeforeClass() {
// bootstrap meta data
EntityTypeMetadata entityTypeMeta = applicationContext.getBean(EntityTypeMetadata.class);
entityTypeMeta.setBackendEnumOptions(newArrayList("test"));
applicationContext.getBean(AttributeMetadata.class).bootstrap(entityTypeMeta);
Map<String, SystemEntityType> systemEntityTypeMap = applicationContext.getBeansOfType(SystemEntityType.class);
new GenericDependencyResolver().resolve(systemEntityTypeMap.values(), SystemEntityType::getDependencies).forEach(systemEntityType -> systemEntityType.bootstrap(entityTypeMeta));
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistrar method register.
public void register(ContextRefreshedEvent event) {
ApplicationContext ctx = event.getApplicationContext();
Map<String, SystemEntityType> systemEntityTypeMap = ctx.getBeansOfType(SystemEntityType.class);
systemEntityTypeMap.values().forEach(this::register);
}
use of org.molgenis.data.meta.SystemEntityType in project molgenis by molgenis.
the class SystemEntityTypeRegistryImplTest method testGetSystemAttributePermittedNotExists.
@Test
public void testGetSystemAttributePermittedNotExists() {
String entityTypeId = "entityType";
SystemEntityType systemEntityType = mock(SystemEntityType.class);
when(systemEntityType.getId()).thenReturn(entityTypeId);
when(systemEntityType.getAllAttributes()).thenReturn(emptyList());
when(permissionService.hasPermission(new EntityTypeIdentity(entityTypeId), EntityTypePermission.COUNT)).thenReturn(true);
systemEntityTypeRegistry.addSystemEntityType(systemEntityType);
assertNull(systemEntityTypeRegistry.getSystemAttribute("attr"));
}
Aggregations