Search in sources :

Example 6 with QuadStore

use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore in project timbuctoo by HuygensING.

the class SummaryPropDataRetrieverTest method createSummaryPropertyReturnsAnEmptyOptionalWhenNoDefaultPropertiesAreConfigured.

@Test
public void createSummaryPropertyReturnsAnEmptyOptionalWhenNoDefaultPropertiesAreConfigured() {
    SummaryPropDataRetriever instance = new SummaryPropDataRetriever("http://example.org/userConfigured", Lists.newArrayList());
    QuadStore quadStore = mock(QuadStore.class);
    Optional<TypedValue> found = instance.createSummaryProperty(subjectWithUri("http://example.org/source"), dataSetWithQuadStore(quadStore));
    assertThat(found, not(is(present())));
}
Also used : QuadStore(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore) TypedValue(nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.TypedValue) Test(org.junit.Test)

Example 7 with QuadStore

use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore in project timbuctoo by HuygensING.

the class SummaryPropDataRetrieverTest method retrieveDefaultPropertyUsesTheFirstQuadFound.

@Test
public void retrieveDefaultPropertyUsesTheFirstQuadFound() {
    List<SummaryProp> defaultProperties = Lists.newArrayList(summaryPropertyWithPath("http://example.org/path", "http://example.org/path2"));
    SummaryPropDataRetriever instance = new SummaryPropDataRetriever("http://example.org/userConfigured", defaultProperties);
    QuadStore quadStore = mock(QuadStore.class);
    CursorQuad foundQuad1 = quadWithObject("http://example.org/objectFound1", Optional.empty());
    CursorQuad foundQuad2 = quadWithObject("http://example.org/objectFound2", Optional.empty());
    given(quadStore.getQuads("http://example.org/source", "http://example.org/path", Direction.OUT, "")).willReturn(Stream.of(foundQuad1, foundQuad2));
    CursorQuad quadWithObjectUriOfPath2 = quadWithObject("http://example.org/objectOfPath2", Optional.empty());
    given(quadStore.getQuads("http://example.org/objectFound1", "http://example.org/path2", Direction.OUT, "")).willReturn(Stream.of(quadWithObjectUriOfPath2));
    instance.createSummaryProperty(subjectWithUri("http://example.org/source"), dataSetWithQuadStore(quadStore));
    verify(quadStore).getQuads("http://example.org/source", "http://example.org/path", Direction.OUT, "");
    verify(quadStore).getQuads("http://example.org/objectFound1", "http://example.org/path2", Direction.OUT, "");
    verify(quadStore, never()).getQuads("http://example.org/objectFound2", "http://example.org/path2", Direction.OUT, "");
}
Also used : QuadStore(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore) CursorQuad(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad) SummaryProp(nl.knaw.huygens.timbuctoo.v5.graphql.defaultconfiguration.SummaryProp) Test(org.junit.Test)

Example 8 with QuadStore

use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore in project timbuctoo by HuygensING.

the class SummaryPropDataRetrieverTest method createSummaryPropertyWalksTheWholePathOfTheConfiguredDefaultProperty.

@Test
public void createSummaryPropertyWalksTheWholePathOfTheConfiguredDefaultProperty() {
    List<SummaryProp> defaultProperties = Lists.newArrayList(summaryPropertyWithPath("http://example.org/path", "http://example.org/path2"));
    SummaryPropDataRetriever instance = new SummaryPropDataRetriever("http://example.org/userConfigured", defaultProperties);
    CursorQuad foundQuad = quadWithObject("http://example.org/objectFound", Optional.empty());
    QuadStore quadStore = mock(QuadStore.class);
    given(quadStore.getQuads("http://example.org/source", "http://example.org/path", Direction.OUT, "")).willReturn(Stream.of(foundQuad));
    instance.createSummaryProperty(subjectWithUri("http://example.org/source"), dataSetWithQuadStore(quadStore));
    InOrder inOrder = inOrder(quadStore);
    inOrder.verify(quadStore).getQuads("http://example.org/source", "http://example.org/path", Direction.OUT, "");
    inOrder.verify(quadStore).getQuads("http://example.org/objectFound", "http://example.org/path2", Direction.OUT, "");
}
Also used : QuadStore(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore) InOrder(org.mockito.InOrder) CursorQuad(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad) SummaryProp(nl.knaw.huygens.timbuctoo.v5.graphql.defaultconfiguration.SummaryProp) Test(org.junit.Test)

Example 9 with QuadStore

use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore in project timbuctoo by HuygensING.

the class SummaryPropDataRetrieverTest method dataSetWithQuadStore.

private DataSet dataSetWithQuadStore(QuadStore quadStore) {
    DataSet dataSet = mock(DataSet.class);
    given(dataSet.getQuadStore()).willReturn(quadStore);
    return dataSet;
}
Also used : DataSet(nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)

Example 10 with QuadStore

use of nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore in project timbuctoo by HuygensING.

the class JsonProvenanceToRdfPatchTest method retractsPreviousRevision.

@Test
public void retractsPreviousRevision() throws Exception {
    String testRetractsRevision = "{\n" + "   \"@type\":\"prov:Activity\",\n" + "   \"http://www.w3.org/ns/prov#generates\":[\n" + "      {\n" + "         \"@type\":\"prov:Entity\",\n" + "         \"@id\":\"_:b2\",\n" + "         \"specializationOf\":{\n" + "            \"@id\":\"http://example.com/the/actual/entitys\"\n" + "         },\n" + "         \"wasRevisionOf\":{\n" + "            \"@id\":\"http://example.org/revision1\"\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.org/revision1", PROV_SPECIALIZATION_OF, "http://example.com/the/actual/entitys", null).with("http://example.com/the/actual/entitys", TIM_LATEST_REVISION, "http://example.org/revision1");
    JsonProvenanceToRdfPatch creator = fromCurrentState(new DocumentLoader(), testRetractsRevision, testQuadStore, EDITOR_URI, "test", CLOCK);
    creator.sendQuads(basicRdfPatchSerializer, s -> {
    }, null);
    List<String> filteredResult = Lists.newArrayList(Collections2.filter(result, Predicates.containsPattern("latestRevision")));
    assertThat(filteredResult, containsInAnyOrder("-<http://example.com/the/actual/entitys> <" + TIM_LATEST_REVISION + "> <http://example.org/revision1" + "> <" + defaultGraph + "> .\n", "+<http://example.com/the/actual/entitys> <" + TIM_LATEST_REVISION + "> <http://timbuctoo.huygens.knaw.nl/static/v5/skolemized/test/b1> <" + defaultGraph + "> .\n"));
}
Also used : QuadStore(nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore) DocumentLoader(com.github.jsonldjava.core.DocumentLoader) Test(org.junit.Test)

Aggregations

QuadStore (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.QuadStore)16 CursorQuad (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad)11 Test (org.junit.Test)11 SummaryProp (nl.knaw.huygens.timbuctoo.v5.graphql.defaultconfiguration.SummaryProp)8 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)5 TypedValue (nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.TypedValue)5 IOException (java.io.IOException)4 List (java.util.List)4 Direction (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.Direction)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DocumentLoader (com.github.jsonldjava.core.DocumentLoader)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Optional (java.util.Optional)3 Stream (java.util.stream.Stream)3 SubjectReference (nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.SubjectReference)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2