Search in sources :

Example 1 with Relation

use of org.molgenis.data.semantic.Relation 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 Relation

use of org.molgenis.data.semantic.Relation 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 Relation

use of org.molgenis.data.semantic.Relation 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 Relation

use of org.molgenis.data.semantic.Relation 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 Relation

use of org.molgenis.data.semantic.Relation 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

Relation (org.molgenis.data.semantic.Relation)22 Attribute (org.molgenis.data.meta.model.Attribute)15 Test (org.testng.annotations.Test)15 LabeledResource (org.molgenis.data.semantic.LabeledResource)12 Model (org.eclipse.rdf4j.model.Model)11 LinkedHashModel (org.eclipse.rdf4j.model.impl.LinkedHashModel)11 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)11 Iterator (java.util.Iterator)10 EntityType (org.molgenis.data.meta.model.EntityType)10 Entity (org.molgenis.data.Entity)9 OntologyTerm (org.molgenis.ontology.core.model.OntologyTerm)9 AbstractMolgenisSpringTest (org.molgenis.data.AbstractMolgenisSpringTest)4 ExplainedAttribute (org.molgenis.semanticsearch.explain.bean.ExplainedAttribute)4 User (org.molgenis.data.security.auth.User)2 SemanticTag (org.molgenis.data.semantic.SemanticTag)2 Ontology (org.molgenis.ontology.core.model.Ontology)2 RunAsSystem (org.molgenis.security.core.runas.RunAsSystem)2 EntityMapping (org.molgenis.semanticmapper.mapping.model.EntityMapping)2 MappingProject (org.molgenis.semanticmapper.mapping.model.MappingProject)2 Instant (java.time.Instant)1