Search in sources :

Example 1 with LabeledResource

use of org.molgenis.data.semantic.LabeledResource 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]");
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) Entity(org.molgenis.data.Entity) Relation(org.molgenis.data.semantic.Relation) LabeledResource(org.molgenis.data.semantic.LabeledResource) Attribute(org.molgenis.data.meta.model.Attribute) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) Iterator(java.util.Iterator) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 2 with LabeledResource

use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.

the class EntityModelWriterTest method testCreateRfdModelMREF.

@Test
public void testCreateRfdModelMREF() {
    List<Attribute> attributeList = singletonList(attribute);
    when(objectEntity.getEntityType()).thenReturn(entityType);
    when(objectEntity.get("attributeName")).thenReturn(refEntity);
    when(objectEntity.getEntities("attributeName")).thenReturn(singletonList(refEntity));
    when(refEntity.getIdValue()).thenReturn("refID");
    when(entityType.getAtomicAttributes()).thenReturn(attributeList);
    when(attribute.getName()).thenReturn("attributeName");
    when(attribute.getDataType()).thenReturn(AttributeType.MREF);
    LabeledResource tag = new LabeledResource("http://IRI.nl", "labelTag3");
    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, http://molgenis01.gcc.rug.nl/fdp/catolog/test/this/refID) [null]");
}
Also used : Relation(org.molgenis.data.semantic.Relation) LabeledResource(org.molgenis.data.semantic.LabeledResource) Attribute(org.molgenis.data.meta.model.Attribute) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) Iterator(java.util.Iterator) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 3 with LabeledResource

use of org.molgenis.data.semantic.LabeledResource 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]");
}
Also used : EntityType(org.molgenis.data.meta.model.EntityType) Entity(org.molgenis.data.Entity) Relation(org.molgenis.data.semantic.Relation) LabeledResource(org.molgenis.data.semantic.LabeledResource) Attribute(org.molgenis.data.meta.model.Attribute) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) Iterator(java.util.Iterator) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 4 with LabeledResource

use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.

the class EntityModelWriterTest method testCreateRfdModelStringAttribute.

@Test
public void testCreateRfdModelStringAttribute() {
    List<Attribute> attributeList = singletonList(attr1);
    when(objectEntity.getEntityType()).thenReturn(entityType);
    when(objectEntity.get("attributeName1")).thenReturn("value1");
    when(objectEntity.getString("attributeName1")).thenReturn("value1");
    when(entityType.getAtomicAttributes()).thenReturn(attributeList);
    when(attr1.getName()).thenReturn("attributeName1");
    when(attr1.getDataType()).thenReturn(AttributeType.STRING);
    LabeledResource tag1 = new LabeledResource("http://IRI1.nl", "tag1Label");
    Multimap<Relation, LabeledResource> tags = ImmutableMultimap.of(Relation.isAssociatedWith, tag1);
    when(tagService.getTagsForAttribute(entityType, attr1)).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://IRI1.nl, \"value1\"^^<http://www.w3.org/2001/XMLSchema#string>) [null]");
}
Also used : Relation(org.molgenis.data.semantic.Relation) LabeledResource(org.molgenis.data.semantic.LabeledResource) Attribute(org.molgenis.data.meta.model.Attribute) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) Iterator(java.util.Iterator) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 5 with LabeledResource

use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.

the class EntityModelWriterTest method testCreateRfdModelXREF.

@Test
public void testCreateRfdModelXREF() {
    List<Attribute> attributeList = singletonList(attr3);
    List<String> refAttributeList = singletonList("refAttr");
    when(objectEntity.getEntityType()).thenReturn(entityType);
    when(objectEntity.get("attributeName3")).thenReturn(refEntity);
    when(objectEntity.getEntity("attributeName3")).thenReturn(refEntity);
    when(refEntity.getEntityType()).thenReturn(refEntityType);
    when(refEntityType.getAttributeNames()).thenReturn(refAttributeList);
    when(refEntity.getIdValue()).thenReturn("refID");
    when(entityType.getAtomicAttributes()).thenReturn(attributeList);
    when(attr3.getName()).thenReturn("attributeName3");
    when(attr3.getDataType()).thenReturn(AttributeType.XREF);
    LabeledResource tag3 = new LabeledResource("http://IRI3.nl", "labelTag3");
    Multimap<Relation, LabeledResource> tags3 = ImmutableMultimap.of(Relation.isAssociatedWith, tag3);
    when(tagService.getTagsForAttribute(entityType, attr3)).thenReturn(tags3);
    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://IRI3.nl, http://molgenis01.gcc.rug.nl/fdp/catolog/test/this/refID) [null]");
}
Also used : Relation(org.molgenis.data.semantic.Relation) LabeledResource(org.molgenis.data.semantic.LabeledResource) Attribute(org.molgenis.data.meta.model.Attribute) Model(org.eclipse.rdf4j.model.Model) LinkedHashModel(org.eclipse.rdf4j.model.impl.LinkedHashModel) Iterator(java.util.Iterator) Test(org.testng.annotations.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

LabeledResource (org.molgenis.data.semantic.LabeledResource)16 Model (org.eclipse.rdf4j.model.Model)12 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)12 Attribute (org.molgenis.data.meta.model.Attribute)12 Relation (org.molgenis.data.semantic.Relation)12 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)12 Test (org.testng.annotations.Test)12 Iterator (java.util.Iterator)10 Entity (org.molgenis.data.Entity)9 EntityType (org.molgenis.data.meta.model.EntityType)9 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 IRI (org.eclipse.rdf4j.model.IRI)1 Resource (org.eclipse.rdf4j.model.Resource)1 Statement (org.eclipse.rdf4j.model.Statement)1 SemanticTag (org.molgenis.data.semantic.SemanticTag)1 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)1