Search in sources :

Example 6 with Quad

use of nl.knaw.huygens.timbuctoo.rml.dto.Quad in project timbuctoo by HuygensING.

the class RmlMapperTest method canGenerateLinks.

@Test
public void canGenerateLinks() {
    final String theNamePredicate = "http://example.org/vocab#name";
    final String theWrittenByPredicate = "http://example.org/vocab#writtenBy";
    RmlMappingDocument rmlMappingDocument = rmlMappingDocument().withTripleMap("http://example.org/personsMap", makePersonMap(theNamePredicate)).withTripleMap("http://example.org/documentsMap", makeDocumentMap(theWrittenByPredicate)).build(makePersonDocumentSourceFactory());
    List<Quad> result = rmlMappingDocument.execute(new ThrowingErrorHandler()).collect(toList());
    assertThat(result, contains(likeTriple(uri("http://www.example.org/persons/1"), uri(theNamePredicate), literal("Bill")), likeTriple(uri("http://www.example.org/documents/1"), uri(theWrittenByPredicate), uri("http://www.example.org/persons/1"))));
}
Also used : Quad(nl.knaw.huygens.timbuctoo.rml.dto.Quad) RmlMappingDocument(nl.knaw.huygens.timbuctoo.rml.rmldata.RmlMappingDocument) Test(org.junit.Test)

Example 7 with Quad

use of nl.knaw.huygens.timbuctoo.rml.dto.Quad in project timbuctoo by HuygensING.

the class RmlMapperTest method canHandleMappingsInTheWrongOrder.

@Test
public void canHandleMappingsInTheWrongOrder() {
    final String theNamePredicate = "http://example.org/vocab#name";
    final String theWrittenByPredicate = "http://example.org/vocab#writtenBy";
    RmlMappingDocument rmlMappingDocument = rmlMappingDocument().withTripleMap("http://example.org/documentsMap", makeDocumentMap(theWrittenByPredicate)).withTripleMap("http://example.org/personsMap", makePersonMap(theNamePredicate)).build(makePersonDocumentSourceFactory());
    List<Quad> result = rmlMappingDocument.execute(new ThrowingErrorHandler()).collect(toList());
    assertThat(result, contains(likeTriple(uri("http://www.example.org/persons/1"), uri(theNamePredicate), literal("Bill")), likeTriple(uri("http://www.example.org/documents/1"), uri(theWrittenByPredicate), uri("http://www.example.org/persons/1"))));
}
Also used : Quad(nl.knaw.huygens.timbuctoo.rml.dto.Quad) RmlMappingDocument(nl.knaw.huygens.timbuctoo.rml.rmldata.RmlMappingDocument) Test(org.junit.Test)

Aggregations

Quad (nl.knaw.huygens.timbuctoo.rml.dto.Quad)7 RmlMappingDocument (nl.knaw.huygens.timbuctoo.rml.rmldata.RmlMappingDocument)6 Test (org.junit.Test)5 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 RdfUri (nl.knaw.huygens.timbuctoo.rml.dto.RdfUri)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Collectors.toList (java.util.stream.Collectors.toList)1