use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getDeletionsReturnsDeletions.
@Test
public void getDeletionsReturnsDeletions() throws Exception {
String deletedValue = "deletedValue";
Map<Object, Object> deletions = Maps.newHashMap();
deletions.put(NAMES_FIELD, newArrayList(createPropertyInput(deletedValue)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("deletions", deletions);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
valuesInQuadStore(NAMES_PRED, deletedValue);
List<Change> deletes = instance.getDeletions(dataSet).collect(toList());
assertThat(deletes.size(), is(1));
assertThat(deletes, contains(likeChange().valuesIsEmpty().withOldValues(new Value(deletedValue, STRING))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method deletesAllValuesOfTheDeletions.
@Test
public void deletesAllValuesOfTheDeletions() 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(false, SUBJECT, PRED1, oldValue, STRING, null, GRAPH);
verify(serializer).addDelQuad(false, SUBJECT, PRED1, oldValue2, STRING, null, GRAPH);
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method addsReplacementsToPlan.
@Test
public void addsReplacementsToPlan() throws Exception {
String newValue = "newValue";
String newValue2 = "newValue2";
String oldValue = "oldValue1";
String oldValue2 = "oldValue2";
addReplacementsToChangeLog(new Replacement(PRED1, newArrayList(new Value(newValue, STRING), new Value(newValue2, STRING)), 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("replacements")), startsWith(DATA_SET_URI + "/replacements"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/replacements"), eq(RDF_TYPE), eq(TIM_VOCAB + "Replacements"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/replacements"), eq(timPredicate("hasReplacement")), startsWith(DATA_SET_URI + "/replacement"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/replacement"), eq(RDF_TYPE), eq(TIM_VOCAB + "Replacement"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/replacement"), eq(timPredicate("hasKey")), eq(PRED1), isNull(), isNull(), eq(GRAPH));
// new values
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/replacement"), 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(timPredicate("type")), eq(STRING), eq(STRING), isNull(), eq(GRAPH));
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(RDF_TYPE), eq(TIM_VOCAB + "Value"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(timPredicate("rawValue")), eq(newValue), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/value"), eq(timPredicate("rawValue")), eq(newValue2), 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));
// old values
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/replacement"), eq(timPredicate("hadValue")), startsWith(DATA_SET_URI + "/oldValue"), isNull(), isNull(), eq(GRAPH));
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/oldValue"), eq(timPredicate("type")), eq(STRING), eq(STRING), isNull(), eq(GRAPH));
// one for each value
verify(serializer, times(2)).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/oldValue"), eq(RDF_TYPE), eq(TIM_VOCAB + "OldValue"), isNull(), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/oldValue"), eq(timPredicate("rawValue")), eq(oldValue), eq(STRING), isNull(), eq(GRAPH));
verify(serializer).addDelQuad(eq(true), startsWith(DATA_SET_URI + "/oldValue"), 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 + "/oldValue"), eq(timPredicate("nextOldValue")), startsWith(DATA_SET_URI + "/oldValue"), isNull(), isNull(), eq(GRAPH));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method removesOldValuesOfAllDeletions.
@Test
public void removesOldValuesOfAllDeletions() throws Exception {
String oldValue = "oldValue";
String oldValue2 = "oldValue2";
addDeletionsToChangeLog(new Deletion(PRED1, newArrayList(new Value(oldValue, STRING))), new Deletion(PRED2, newArrayList(new Value(oldValue2, STRING))));
GraphQlToRdfPatch instance = new GraphQlToRdfPatch(GRAPH, SUBJECT, USER_URI, changeLog);
instance.sendQuads(serializer, s -> {
}, dataSet);
verify(serializer).addDelQuad(false, SUBJECT, PRED1, oldValue, STRING, null, GRAPH);
verify(serializer).addDelQuad(false, SUBJECT, PRED2, oldValue2, STRING, null, GRAPH);
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class GraphQlToRdfPatchTest method deletionsAreExecutedBeforeAdditions.
@Test
public void deletionsAreExecutedBeforeAdditions() throws Exception {
String addedValue = "newValue";
String oldValue = "oldValue";
addAdditionsToChangeLog(new Change(new Graph(GRAPH), SUBJECT, PRED1, newArrayList(new Value(addedValue, STRING)), null));
addDeletionsToChangeLog(new Deletion(PRED1, newArrayList(new Value(oldValue, 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);
}
Aggregations