Search in sources :

Example 86 with Attribute

use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.

the class UnitResolverImplTest method resolveUnitLabelNoUnitDescriptionNoUnit.

@Test
public void resolveUnitLabelNoUnitDescriptionNoUnit() {
    Attribute attr = attrMetaFactory.create().setName("attr").setLabel("weight").setDescription("weight");
    Unit<? extends Quantity> unit = unitResolverImpl.resolveUnit(attr, null);
    assertNull(unit);
}
Also used : Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 87 with Attribute

use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.

the class UnitResolverImplTest method resolveUnitLabelNoUnitDescriptionWithUnit_unitOntologyMatch.

@Test
public void resolveUnitLabelNoUnitDescriptionWithUnit_unitOntologyMatch() {
    Attribute attr = attrMetaFactory.create().setName("attr").setLabel("label").setDescription("height (centimeter)");
    Unit<? extends Quantity> unit = unitResolverImpl.resolveUnit(attr, null);
    assertEquals(unit, Unit.valueOf("cm"));
}
Also used : Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 88 with Attribute

use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.

the class UnitResolverImplTest method resolveUnitLabelNoUnitDescriptionWithUnit_unitOntologyMatch_kgm2.

@Test
public void resolveUnitLabelNoUnitDescriptionWithUnit_unitOntologyMatch_kgm2() {
    Attribute attr = attrMetaFactory.create().setName("attr").setLabel("label").setDescription("area density (kg/m^2)");
    Unit<? extends Quantity> unit = unitResolverImpl.resolveUnit(attr, null);
    assertEquals(unit, Unit.valueOf("kg/m²"));
}
Also used : Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 89 with Attribute

use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.

the class UnitResolverImplTest method resolveUnitLabelNoUnit.

@Test
public void resolveUnitLabelNoUnit() {
    Attribute attr = attrMetaFactory.create().setName("attr").setLabel("weight").setDescription(null);
    Unit<? extends Quantity> unit = unitResolverImpl.resolveUnit(attr, null);
    assertNull(unit);
}
Also used : Attribute(org.molgenis.data.meta.model.Attribute) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Example 90 with Attribute

use of org.molgenis.data.meta.model.Attribute in project molgenis by molgenis.

the class EntityMappingRepositoryImplTest method testUpsert.

@Test
public void testUpsert() {
    Attribute targetAttribute = attrMetaFactory.create().setName("targetAttribute");
    List<Attribute> sourceAttributes = Lists.newArrayList();
    EntityType sourceEntityType = entityTypeFactory.create("source");
    EntityType targetEntityType = entityTypeFactory.create("target");
    targetEntityType.addAttribute(targetAttribute);
    List<AttributeMapping> attributeMappings = Lists.newArrayList();
    attributeMappings.add(new AttributeMapping("1", "targetAttribute", targetAttribute, "algorithm", sourceAttributes, CURATED.toString()));
    Collection<EntityMapping> entityMappings = singletonList(new EntityMapping(AUTO_ID, sourceEntityType, targetEntityType, attributeMappings));
    Entity attributeMappingEntity = new DynamicEntity(attrMappingMeta);
    attributeMappingEntity.set(EntityMappingMetaData.IDENTIFIER, AUTO_ID);
    attributeMappingEntity.set(AttributeMappingMetaData.TARGET_ATTRIBUTE, "targetAttribute");
    attributeMappingEntity.set(AttributeMappingMetaData.SOURCE_ATTRIBUTES, "");
    attributeMappingEntity.set(AttributeMappingMetaData.ALGORITHM, "algorithm");
    attributeMappingEntity.set(AttributeMappingMetaData.ALGORITHM_STATE, CURATED.toString());
    List<Entity> attributeMappingEntities = Lists.newArrayList();
    attributeMappingEntities.add(attributeMappingEntity);
    List<Entity> entityMappingEntities = Lists.newArrayList();
    Entity entityMappingEntity = new DynamicEntity(entityMappingMeta);
    entityMappingEntity.set(EntityMappingMetaData.IDENTIFIER, AUTO_ID);
    entityMappingEntity.set(EntityMappingMetaData.SOURCE_ENTITY_TYPE, "source");
    entityMappingEntity.set(EntityMappingMetaData.TARGET_ENTITY_TYPE, "target");
    entityMappingEntity.set(EntityMappingMetaData.ATTRIBUTE_MAPPINGS, attributeMappingEntities);
    entityMappingEntities.add(entityMappingEntity);
    Assert.assertTrue(EntityUtils.equals(entityMappingRepository.upsert(entityMappings).get(0), entityMappingEntities.get(0)));
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) EntityMapping(org.molgenis.semanticmapper.mapping.model.EntityMapping) DynamicEntity(org.molgenis.data.support.DynamicEntity) Entity(org.molgenis.data.Entity) Attribute(org.molgenis.data.meta.model.Attribute) DynamicEntity(org.molgenis.data.support.DynamicEntity) AttributeMapping(org.molgenis.semanticmapper.mapping.model.AttributeMapping) Test(org.testng.annotations.Test) AbstractMolgenisSpringTest(org.molgenis.data.AbstractMolgenisSpringTest)

Aggregations

Attribute (org.molgenis.data.meta.model.Attribute)600 Test (org.testng.annotations.Test)351 EntityType (org.molgenis.data.meta.model.EntityType)321 Entity (org.molgenis.data.Entity)109 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)54 DynamicEntity (org.molgenis.data.support.DynamicEntity)53 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)47 Stream (java.util.stream.Stream)39 AttributeType (org.molgenis.data.meta.AttributeType)34 QueryImpl (org.molgenis.data.support.QueryImpl)29 ExplainedAttribute (org.molgenis.semanticsearch.explain.bean.ExplainedAttribute)29 UnexpectedEnumException (org.molgenis.util.UnexpectedEnumException)28 BeforeMethod (org.testng.annotations.BeforeMethod)20 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)18 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 Collectors.toList (java.util.stream.Collectors.toList)17 Relation (org.molgenis.data.semantic.Relation)17 Objects.requireNonNull (java.util.Objects.requireNonNull)16 MolgenisDataException (org.molgenis.data.MolgenisDataException)16 Package (org.molgenis.data.meta.model.Package)16