Search in sources :

Example 6 with DocumentLoader

use of com.github.jsonldjava.core.DocumentLoader in project timbuctoo by HuygensING.

the class JsonProvenanceToRdfPatchTest method testSingleAddition.

@Test
public void testSingleAddition() throws Exception {
    String testAdditionWithType = "{\n" + "   \"@type\":\"prov:Activity\",\n" + "   \"http://www.w3.org/ns/prov#generates\":[\n" + "      {\n" + "         \"@type\":\"prov:Entity\",\n" + "         \"specializationOf\":{\n" + "            \"@id\":\"http://example.com/the/actual/entitys\"\n" + "         },\n" + "         \"additions\":[\n" + "            {\n" + "               \"@type\":\"http://timbuctoo.huygens.knaw.nl/v5/vocabulary#mutation\",\n" + "               \"predicate\":\"http://example.org/pred2\",\n" + "               \"value\":\"extra value\"\n" + "            },\n" + "            {\n" + "               \"@type\":\"http://timbuctoo.huygens.knaw.nl/v5/vocabulary#mutation\",\n" + "               \"predicate\":\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\",\n" + "               \"value\":{\n" + "                  \"@id\":\"http://timbuctoo.huygens.knaw.nl/static/v5/Persons\"\n" + "               }\n" + "            }\n" + "         ]\n" + "      }\n" + "   ],\n" + context + "}";
    JsonProvenanceToRdfPatch creator = fromCurrentState(new DocumentLoader(), testAdditionWithType, new DummyQuadStore(), EDITOR_URI, "test", CLOCK);
    creator.sendQuads(basicRdfPatchSerializer, s -> {
    }, null);
    List<String> filteredResult = Lists.newArrayList(Collections2.filter(result, Predicates.containsPattern("http://example.org/pred2")));
    assertThat(filteredResult, containsInAnyOrder("+<http://example.com/the/actual/entitys> <http://example.org/pred2> \"extra value\"" + "^^<http://www.w3.org/2001/XMLSchema#string> <" + defaultGraph + "> .\n", "+<http://timbuctoo.huygens.knaw.nl/static/v5/skolemized/test/b2> " + "<http://timbuctoo.huygens.knaw.nl/v5/vocabulary#predicate> " + "\"http://example.org/pred2\"^^<http://www.w3.org/2001/XMLSchema#string> <" + defaultGraph + "> .\n"));
}
Also used : DocumentLoader(com.github.jsonldjava.core.DocumentLoader) Test(org.junit.Test)

Example 7 with DocumentLoader

use of com.github.jsonldjava.core.DocumentLoader in project timbuctoo by HuygensING.

the class JsonProvenanceToRdfPatchTest method testReplacement.

@Test
public void testReplacement() throws Exception {
    String testReplacement = "{\n" + "   \"@type\":\"prov:Activity\",\n" + "   \"http://www.w3.org/ns/prov#generates\":[\n" + "      {\n" + "         \"@type\":\"prov:Entity\",\n" + "         \"specializationOf\":{\n" + "            \"@id\":\"http://example.com/the/actual/entitys\"\n" + "         },\n" + "         \"replacements\":[\n" + "            {\n" + "               \"@type\":\"http://timbuctoo.huygens.knaw.nl/v5/vocabulary#mutation\",\n" + "               \"predicate\":\"http://example.org/pred1\",\n" + "               \"value\":\"value1\"\n" + "            }\n" + "         ]\n" + "      }\n" + "   ],\n" + context + "}";
    QuadStore testQuadStore = new DummyQuadStore().with("http://example.com/the/actual/entitys", "http://example.org/pred1", "old value", "http://www.w3.org/2001/XMLSchema#string");
    JsonProvenanceToRdfPatch creator = fromCurrentState(new DocumentLoader(), testReplacement, testQuadStore, EDITOR_URI, "test", CLOCK);
    creator.sendQuads(basicRdfPatchSerializer, s -> {
    }, null);
    List<String> filteredResult = Lists.newArrayList(Collections2.filter(result, Predicates.containsPattern("http://example.org/pred")));
    filteredResult = Lists.newArrayList(Collections2.filter(filteredResult, Predicates.not(Predicates.containsPattern("skolemized"))));
    assertThat(filteredResult, containsInAnyOrder("-<http://example.com/the/actual/entitys> <http://example.org/pred1> \"old value\"" + "^^<http://www.w3.org/2001/XMLSchema#string> <" + defaultGraph + "> .\n", "+<http://example.com/the/actual/entitys> <http://example.org/pred1> \"value1\"" + "^^<http://www.w3.org/2001/XMLSchema#string> <" + defaultGraph + "> .\n"));
}
Also used : QuadStore(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore) DocumentLoader(com.github.jsonldjava.core.DocumentLoader) Test(org.junit.Test)

Aggregations

DocumentLoader (com.github.jsonldjava.core.DocumentLoader)7 Test (org.junit.Test)7 QuadStore (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore)3