use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelSTRINGKeywords.
@Test
public void testCreateRfdModelSTRINGKeywords() {
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);
String value = "molgenis,genetics,fair";
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getString("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.STRING);
LabeledResource tag = new LabeledResource("http://www.w3.org/ns/dcat#keyword", "keywords");
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(), 3);
List<String> statements = result.stream().map(Statement::toString).collect(toList());
assertEquals(statements, Arrays.asList("(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://www.w3.org/ns/dcat#keyword, \"molgenis\"^^<http://www.w3.org/2001/XMLSchema#string>) [null]", "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://www.w3.org/ns/dcat#keyword, \"genetics\"^^<http://www.w3.org/2001/XMLSchema#string>) [null]", "(http://molgenis01.gcc.rug.nl/fdp/catolog/test/this, http://www.w3.org/ns/dcat#keyword, \"fair\"^^<http://www.w3.org/2001/XMLSchema#string>) [null]"));
}
use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelDATE.
@Test
public void testCreateRfdModelDATE() {
// 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);
LocalDate value = LocalDate.of(2013, Month.AUGUST, 12);
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getLocalDate("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.DATE);
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, \"2013-08-12\"^^<http://www.w3.org/2001/XMLSchema#date>) [null]");
}
use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelDATETIME.
@Test
public void testCreateRfdModelDATETIME() {
// 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);
Instant value = Instant.parse("2011-12-03T10:15:30Z");
when(objectEntity.get("attributeName")).thenReturn(value);
when(objectEntity.getInstant("attributeName")).thenReturn(value);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.DATE_TIME);
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, \"2011-12-03T10:15:30Z\"^^<http://www.w3.org/2001/XMLSchema#dateTime>) [null]");
}
use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelBOOL.
@Test
public void testCreateRfdModelBOOL() {
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);
when(objectEntity.get("attributeName")).thenReturn(true);
when(objectEntity.getBoolean("attributeName")).thenReturn(true);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attribute.getName()).thenReturn("attributeName");
when(attribute.getDataType()).thenReturn(AttributeType.BOOL);
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, \"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>) [null]");
}
use of org.molgenis.data.semantic.LabeledResource in project molgenis by molgenis.
the class EntityModelWriterTest method testCreateRfdModelIntAttribute.
@Test
public void testCreateRfdModelIntAttribute() {
List<Attribute> attributeList = singletonList(attr2);
when(objectEntity.getEntityType()).thenReturn(entityType);
when(objectEntity.get("attributeName2")).thenReturn(2);
when(objectEntity.getInt("attributeName2")).thenReturn(2);
when(entityType.getAtomicAttributes()).thenReturn(attributeList);
when(attr2.getName()).thenReturn("attributeName2");
when(attr2.getDataType()).thenReturn(AttributeType.INT);
LabeledResource tag2 = new LabeledResource("http://IRI2.nl", "tag2Label");
Multimap<Relation, LabeledResource> tags2 = ImmutableMultimap.of(Relation.isAssociatedWith, tag2);
when(tagService.getTagsForAttribute(entityType, attr2)).thenReturn(tags2);
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://IRI2.nl, \"2\"^^<http://www.w3.org/2001/XMLSchema#int>) [null]");
}
Aggregations