use of org.molgenis.data.meta.model.Attribute 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.Attribute 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]");
}
use of org.molgenis.data.meta.model.Attribute 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]");
}
use of org.molgenis.data.meta.model.Attribute 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]");
}
use of org.molgenis.data.meta.model.Attribute 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]");
}
Aggregations