use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method removesAllOldValuesOfReplacements.
@Test
public void removesAllOldValuesOfReplacements() throws Exception {
String oldValue = "oldValue";
String oldValue2 = "oldValue2";
String addedValue = "newValue";
String addedValue2 = "newValue2";
addReplacementsToChangeLog(new Replacement(PRED1, newArrayList(new Value(addedValue, STRING), new Value(addedValue2, STRING)), newArrayList(new Value(oldValue, STRING), new Value(oldValue2, STRING))));
GraphQlToRdfPatch instance = new GraphQlToRdfPatch(GRAPH, SUBJECT, USER_URI, changeLog);
instance.sendQuads(serializer, s -> {
}, dataSet);
InOrder inOrder = inOrder(serializer);
inOrder.verify(serializer).addDelQuad(false, SUBJECT, PRED1, oldValue, STRING, null, GRAPH);
inOrder.verify(serializer).addDelQuad(false, SUBJECT, PRED1, oldValue2, STRING, null, GRAPH);
inOrder.verify(serializer).addDelQuad(true, SUBJECT, PRED1, addedValue, STRING, null, GRAPH);
inOrder.verify(serializer).addDelQuad(true, SUBJECT, PRED1, addedValue2, STRING, null, GRAPH);
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method addsDeletionsToPlan.
@Test
public void addsDeletionsToPlan() throws Exception {
String oldValue = "oldValue";
String oldValue2 = "oldValue2";
addDeletionsToChangeLog(new Deletion(PRED1, newArrayList(new Value(oldValue, STRING), new Value(oldValue2, STRING))));
GraphQlToRdfPatch instance = new GraphQlToRdfPatch(GRAPH, SUBJECT, USER_URI, changeLog);
instance.sendQuads(serializer, s -> {
}, dataSet);
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/plan"), eq(timPredicate("deletions")), startsWith(DATA_SET_URI + "/deletions"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/deletions"), eq(RDF_TYPE), eq(TIM_VOCAB + "Deletions"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/deletions"), eq(timPredicate("hasDeletion")), startsWith(DATA_SET_URI + "/deletion"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/deletion"), eq(RDF_TYPE), eq(TIM_VOCAB + "Deletion"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/deletion"), eq(timPredicate("hasKey")), eq(PRED1), isNull(), isNull(), eq(GRAPH));
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/deletion"), eq(timPredicate("hasValue")), startsWith(DATA_SET_URI + "/value"), isNull(), isNull(), eq(GRAPH));
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(RDF_TYPE), eq(timType("Value")), isNull(), isNull(), eq(GRAPH));
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(timPredicate("type")), eq(STRING), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(timPredicate("rawValue")), eq(oldValue), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(timPredicate("rawValue")), eq(oldValue2), eq(STRING), isNull(), eq(GRAPH));
// TODO find a better way to test
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(timPredicate("nextValue")), startsWith(DATA_SET_URI + "/value"), isNull(), isNull(), eq(GRAPH));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method addsCustomProvenanceToPlan.
@Test
public void addsCustomProvenanceToPlan() throws Exception {
String value1 = "value1";
String value2 = "value2";
addProvenanceToChangeLog(new Provenance(PRED1, newArrayList(new Value(value1, STRING))), new Provenance(PRED2, newArrayList(new Value(value2, STRING))));
GraphQlToRdfPatch instance = new GraphQlToRdfPatch(GRAPH, SUBJECT, USER_URI, changeLog);
instance.sendQuads(serializer, s -> {
}, dataSet);
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/plan"), eq(timPredicate("hasCustomProv")), startsWith(DATA_SET_URI + "/customProv"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/customProv"), eq(RDF_TYPE), eq(timType("CustomProv")), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(SUBJECT), eq(PRED1), eq(value1), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(SUBJECT), eq(PRED2), eq(value2), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/customProv"), eq(PRED1), eq(value1), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/customProv"), eq(PRED2), eq(value2), eq(STRING), isNull(), eq(GRAPH));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method addsAndRemovesValuesOfAllReplacements.
@Test
public void addsAndRemovesValuesOfAllReplacements() throws Exception {
String addedValue = "newValue";
String addedValue2 = "newValue2";
String oldValue = "oldValue";
String oldValue2 = "oldValue2";
addReplacementsToChangeLog(new Replacement(PRED1, newArrayList(new Value(addedValue, STRING)), newArrayList(new Value(oldValue, STRING))), new Replacement(PRED2, newArrayList(new Value(addedValue2, STRING)), newArrayList(new Value(oldValue2, STRING))));
GraphQlToRdfPatch instance = new GraphQlToRdfPatch(GRAPH, SUBJECT, USER_URI, changeLog);
instance.sendQuads(serializer, s -> {
}, dataSet);
InOrder inOrder = inOrder(serializer);
inOrder.verify(serializer).addDelQuad(false, SUBJECT, PRED1, oldValue, STRING, null, GRAPH);
inOrder.verify(serializer).addDelQuad(true, SUBJECT, PRED1, addedValue, STRING, null, GRAPH);
inOrder.verify(serializer).addDelQuad(false, SUBJECT, PRED2, oldValue2, STRING, null, GRAPH);
inOrder.verify(serializer).addDelQuad(true, SUBJECT, PRED2, addedValue2, STRING, null, GRAPH);
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class ProvenanceChangeLogTest method getProvenanceForListField.
@Test
public void getProvenanceForListField() throws Exception {
CustomProvenance customProvenance = CustomProvenance.getCustomProvenance(ImmutableMap.of("fields", Lists.newArrayList(ImmutableMap.of("uri", NAME_URI, "isList", true, "valueType", STRING))));
when(dataSet.getCustomProvenance()).thenReturn(customProvenance);
String value1 = "value1";
String value2 = "value2";
Map<Object, Object> provenance = Maps.newHashMap();
provenance.put(NAME_FIELD, newArrayList(createPropertyInput(value1), createPropertyInput(value2)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("provenance", provenance);
ProvenanceChangeLog instance = new ProvenanceChangeLog(entity);
List<Change> provChanges = instance.getProvenance(dataSet, SUBJECT).collect(toList());
assertThat(provChanges.size(), is(1));
assertThat(provChanges.get(0), is(likeChange().withSubject(SUBJECT).withPredicate(NAME_URI).withValues(new Value(value1, STRING), new Value(value2, STRING)).oldValuesIsEmpty()));
}
Aggregations