use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class SummaryPropDataRetrieverTest method createSummaryPropertySearchesUntilItFindsAValue.
@Test
public void createSummaryPropertySearchesUntilItFindsAValue() {
List<SummaryProp> defaultProperties = Lists.newArrayList(summaryPropertyWithPath(DEFAULT_PROP_1), summaryPropertyWithPath(DEFAULT_PROP_2), summaryPropertyWithPath(DEFAULT_PROP_3));
SummaryPropDataRetriever instance = new SummaryPropDataRetriever(USER_CONFIGURED_PATH, defaultProperties);
QuadStore quadStore = mock(QuadStore.class);
CursorQuad foundQuad = quadWithObject(OBJECT_1, Optional.empty());
given(foundQuad.getObject()).willReturn("http://example.org/value");
given(quadStore.getQuadsInGraph(SOURCE, DEFAULT_PROP_2, Direction.OUT, "", Optional.of(new Graph(GRAPH)))).willReturn(Stream.of(foundQuad));
Optional<TypedValue> found = instance.createSummaryProperty(subjectWithUriAndGraph(SOURCE, Optional.of(new Graph(GRAPH))), dataSetWithQuadStore(quadStore), COLLECTION);
assertThat(found, is(present()));
assertThat(found.get(), hasProperty("value", is("http://example.org/value")));
verify(quadStore).getQuadsInGraph(SOURCE, DEFAULT_PROP_1, Direction.OUT, "", Optional.of(new Graph(GRAPH)));
verify(quadStore).getQuadsInGraph(SOURCE, DEFAULT_PROP_2, Direction.OUT, "", Optional.of(new Graph(GRAPH)));
verify(quadStore, never()).getQuadsInGraph(anyString(), eq(DEFAULT_PROP_3), eq(Direction.OUT), eq(""), eq(Optional.of(new Graph(GRAPH))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class SummaryPropDataRetrieverTest method createSummaryPropertySupportsInverseRelations.
@Test
public void createSummaryPropertySupportsInverseRelations() {
List<SummaryProp> defaultProperties = Lists.newArrayList(summaryPropertyWithPath(DEFAULT_PROP_1, Direction.IN));
SummaryPropDataRetriever instance = new SummaryPropDataRetriever(USER_CONFIGURED_PATH, defaultProperties);
QuadStore quadStore = mock(QuadStore.class);
CursorQuad foundQuad = quadWithObject(OBJECT_1, Optional.empty());
given(foundQuad.getObject()).willReturn("http://example.org/value");
instance.createSummaryProperty(subjectWithUriAndGraph(SOURCE, Optional.of(new Graph(GRAPH))), dataSetWithQuadStore(quadStore), COLLECTION);
verify(quadStore).getQuadsInGraph(SOURCE, DEFAULT_PROP_1, Direction.IN, "", Optional.of(new Graph(GRAPH)));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class DerivedInputTypeSchemaGeneratorTest method returnsAnEmptyStringForReadOnlyTypes.
@Test
public void returnsAnEmptyStringForReadOnlyTypes() {
DerivedInputTypeSchemaGenerator instance = new DerivedInputTypeSchemaGenerator(READ_ONLY_TYPE, ROOT_TYPE, graphQlNameGenerator, derivedSchemaContainer, readOnlyChecker, new CustomProvenance(Collections.emptyList()));
Predicate predicate = predicate().withName("http://example.com/value").hasDirection(Direction.OUT).withValueType(RdfConstants.STRING).build();
instance.valueField(null, predicate, RdfConstants.STRING);
String schema = instance.getSchema().toString();
assertThat(schema, isEmptyString());
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class DerivedInputTypeSchemaGeneratorTest method addsADeprecatedInputFieldForSingleForAListThatWasASingle.
@Test
public void addsADeprecatedInputFieldForSingleForAListThatWasASingle() {
Predicate valueList = predicate().withName("http://example.com/wasSingleList").isList().hasBeenSingular().hasDirection(Direction.OUT).build();
graphQlNameForPredicate("http://example.com/wasSingleList", false, "short_wasSingle");
graphQlNameForPredicate("http://example.com/wasSingleList", true, "short_wasSingleList");
instanceNoProv.valueField(null, valueList, RdfConstants.STRING);
String schema = instanceNoProv.getSchema().toString();
assertThat(schema, allOf(containsString("input TypeReplacementsInput {\n" + " short_wasSingleList: [PropertyInput!]\n" + " short_wasSingle: PropertyInput" + " @deprecated(reason: \"This property only returns the first value of the list. Use the *List version\")\n" + "}\n\n")));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class SchemaGenerationTest method addAValidIncomingPredicateToTheNewType.
/* When the SUBJECT_C RDF_TYPE TYPE_1 is asserted in a a separate update, while ex:baz did not have a type before.
* Then I expect the RDF_TYPE to get an inverse of the ex:links predicate that points to TYPE_2
*
* But in the current code that does not happen. Instead ex:type gets an ex:links
* predicate that has no reference or value types
*/
@Test
public void addAValidIncomingPredicateToTheNewType() throws Exception {
BdbNonPersistentEnvironmentCreator dataStoreFactory = new BdbNonPersistentEnvironmentCreator();
final BdbSchemaStore schema = new BdbSchemaStore(new BdbBackedData(dataStoreFactory.getDatabase(USER, DATA_SET, "schema", false, STRING_BINDING, STRING_BINDING, STRING_IS_CLEAN_HANDLER)), mock(ImportStatus.class));
final StoreUpdater storeUpdater = createInstance(dataStoreFactory, schema);
storeUpdater.start(0);
storeUpdater.onQuad(true, SUBJECT_A, PROP_III, SUBJECT_C, null, null, null);
storeUpdater.onQuad(true, SUBJECT_A, RDF_TYPE, TYPE_2, null, null, null);
storeUpdater.commit();
storeUpdater.start(1);
storeUpdater.onQuad(true, SUBJECT_C, RDF_TYPE, TYPE_1, null, null, null);
storeUpdater.commit();
assertThat(schema.getStableTypes(), hasEntry(is(TYPE_1), hasProperty("predicates", hasItem(predicate().withName(PROP_III).withDirection(Direction.IN).withReferenceType(TYPE_2)))));
}
Aggregations