Search in sources :

Example 1 with GenericDependencyResolver

use of org.molgenis.data.util.GenericDependencyResolver 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));
}
Also used : EntityTypeMetadata(org.molgenis.data.meta.model.EntityTypeMetadata) AttributeMetadata(org.molgenis.data.meta.model.AttributeMetadata) SystemEntityType(org.molgenis.data.meta.SystemEntityType) GenericDependencyResolver(org.molgenis.data.util.GenericDependencyResolver) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with GenericDependencyResolver

use of org.molgenis.data.util.GenericDependencyResolver in project molgenis by molgenis.

the class EntityTypeDependencyResolverTest method setUpBeforeMethod.

@BeforeMethod
public void setUpBeforeMethod() {
    // do not mock generic dependency resolver to simplify test writing
    GenericDependencyResolver genericDependencyResolver = new GenericDependencyResolver();
    entityTypeDependencyResolver = new EntityTypeDependencyResolver(genericDependencyResolver);
    entityType0 = when(mock(EntityType.class).getId()).thenReturn("entity0").getMock();
    entityType1 = when(mock(EntityType.class).getId()).thenReturn("entity1").getMock();
    entityType2 = when(mock(EntityType.class).getId()).thenReturn("entity2").getMock();
    entityType3 = when(mock(EntityType.class).getId()).thenReturn("entity3").getMock();
    attr0 = when(mock(Attribute.class).getName()).thenReturn("attr0").getMock();
    attr1 = when(mock(Attribute.class).getName()).thenReturn("attr1").getMock();
    attr2 = when(mock(Attribute.class).getName()).thenReturn("attr2").getMock();
    attr3 = when(mock(Attribute.class).getName()).thenReturn("attr3").getMock();
    when(entityType0.getOwnAllAttributes()).thenReturn(singleton(attr0));
    when(entityType1.getOwnAllAttributes()).thenReturn(singleton(attr1));
    when(entityType2.getOwnAllAttributes()).thenReturn(singleton(attr2));
    when(entityType3.getOwnAllAttributes()).thenReturn(singleton(attr3));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) Attribute(org.molgenis.data.meta.model.Attribute) GenericDependencyResolver(org.molgenis.data.util.GenericDependencyResolver) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

GenericDependencyResolver (org.molgenis.data.util.GenericDependencyResolver)2 SystemEntityType (org.molgenis.data.meta.SystemEntityType)1 Attribute (org.molgenis.data.meta.model.Attribute)1 AttributeMetadata (org.molgenis.data.meta.model.AttributeMetadata)1 EntityType (org.molgenis.data.meta.model.EntityType)1 EntityTypeMetadata (org.molgenis.data.meta.model.EntityTypeMetadata)1 BeforeClass (org.testng.annotations.BeforeClass)1 BeforeMethod (org.testng.annotations.BeforeMethod)1