use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class EntityTypeUtilsTest method isSystemEntityIfInSystemSubPackage.
@Test
public void isSystemEntityIfInSystemSubPackage() {
EntityType entity = mock(EntityType.class);
Package entityPackage = mock(Package.class);
when(entity.getPackage()).thenReturn(entityPackage);
when(entityPackage.getId()).thenReturn("not-system");
when(entity.getId()).thenReturn("sys_foo_bar_Entity");
assertTrue(EntityTypeUtils.isSystemEntity(entity));
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class EntityTypeUtilsTest method isSystemEntityIfInSystemPackage.
@Test
public void isSystemEntityIfInSystemPackage() {
EntityType entity = mock(EntityType.class);
Package entityPackage = mock(Package.class);
when(entity.getPackage()).thenReturn(entityPackage);
when(entityPackage.getId()).thenReturn("sys");
assertTrue(EntityTypeUtils.isSystemEntity(entity));
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class StringExpressionEvaluatorTest method createEntity.
@BeforeTest
public void createEntity() {
entityType = when(mock(EntityType.class).getId()).thenReturn("Source").getMock();
Attribute idAttr = when(mock(Attribute.class).getName()).thenReturn("Identifier").getMock();
when(idAttr.getDataType()).thenReturn(INT);
Attribute intAttr = when(mock(Attribute.class).getName()).thenReturn("Int").getMock();
when(intAttr.getDataType()).thenReturn(INT);
Attribute stringAttr = when(mock(Attribute.class).getName()).thenReturn("String").getMock();
when(stringAttr.getDataType()).thenReturn(STRING);
Attribute nonNumericStringAttr = when(mock(Attribute.class).getName()).thenReturn("NonNumericString").getMock();
when(nonNumericStringAttr.getDataType()).thenReturn(STRING);
Attribute longAttr = when(mock(Attribute.class).getName()).thenReturn("Long").getMock();
when(longAttr.getDataType()).thenReturn(LONG);
when(entityType.getIdAttribute()).thenReturn(idAttr);
when(entityType.getId()).thenReturn("test");
when(entityType.getAttribute("Identifier")).thenReturn(idAttr);
when(entityType.getAttribute("Int")).thenReturn(intAttr);
when(entityType.getAttribute("String")).thenReturn(stringAttr);
when(entityType.getAttribute("NonNumericString")).thenReturn(nonNumericStringAttr);
when(entityType.getAttribute("Long")).thenReturn(longAttr);
entity = new DynamicEntity(entityType);
entity.set("Int", 1);
entity.set("String", "12");
entity.set("Long", 10L);
entity.set("NonNumericString", "Hello World!");
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelDECIMAL.
@Test
public void testCreateRfdModelDECIMAL() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
double value = 10.0;
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getDouble("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.DECIMAL);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"10.0\"^^<http://www.w3.org/2001/XMLSchema#double>) [null]");
}
use of org.molgenis.data.meta.model.EntityType in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelLONG.
@Test
public void testCreateRfdModelLONG() {
// public Model createRdfModel(String subjectIRI, Entity objectEntity)
Entity objectEntity = mock(Entity.class);
EntityType entityType = mock(EntityType.class);
Attribute attribute = mock(Attribute.class);
List<Attribute> attributeList = singletonList(attribute);
when(objectEntity.getEntityType()).thenReturn(entityType);
long value = 987654321L;
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getLong("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.LONG);
LabeledResource tag = new LabeledResource("http://IRI.nl", "tag label");
Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag);
when(tagService.getTagsForAttribute(entityType, attribute)).thenReturn(tags);
Model result = writer.createRdfModel("http://molgenis01.gcc.rug.nl/fdp/catolog/test/this", objectEntity);
assertEquals(result.size(), 1);
Iterator results = result.iterator();
assertEquals(results.next().toString(), "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://IRI.nl, \"987654321\"^^<http://www.w3.org/2001/XMLSchema#long>) [null]");
}
Aggregations