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);
}
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"));
}
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²"));
}
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);
}
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)));
}
Aggregations