use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class CreateMutationChangeLogTest method getAdditionsReturnsCreations.
@Test
public void getAdditionsReturnsCreations() throws Exception {
String addedValue = "newValue";
Map<Object, Object> creations = Maps.newHashMap();
creations.put(NAMES_FIELD, createPropertyInput(addedValue));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("creations", creations);
CreateMutationChangeLog instance = new CreateMutationChangeLog(new Graph(GRAPH), SUBJECT, TYPE_URI, entity);
List<Change> adds = instance.getAdditions(dataSet).collect(toList());
assertThat(adds.size(), is(2));
assertThat(adds.get(0), is(likeChange().withValues(new Value(TYPE_URI, null)).oldValuesIsEmpty()));
assertThat(adds.get(1), is(likeChange().withValues(new Value(addedValue, STRING)).oldValuesIsEmpty()));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getDeletionsForListReturnsDeletions.
@Test
public void getDeletionsForListReturnsDeletions() throws Exception {
String existingValue1 = "existingValue1";
String existingValue2 = "existingValue2";
Map<Object, Object> deletions = Maps.newHashMap();
deletions.put(NAMES_FIELD, newArrayList(createPropertyInput(existingValue2)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("deletions", deletions);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
valuesInQuadStore(NAMES_PRED, existingValue1, existingValue2);
List<Change> deletes = instance.getDeletions(dataSet).collect(toList());
assertThat(deletes.size(), is(1));
assertThat(deletes, contains(likeChange().valuesIsEmpty().withOldValues(new Value(existingValue2, STRING))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getDeletionsReturnsReplacements.
@Test
public void getDeletionsReturnsReplacements() throws Exception {
String existingValue = "existingValue";
Map<Object, Object> replacements = Maps.newHashMap();
replacements.put(NAMES_FIELD, null);
Map<Object, Object> entity = Maps.newHashMap();
entity.put("replacements", replacements);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
valuesInQuadStore(NAMES_PRED, existingValue);
List<Change> deletes = instance.getDeletions(dataSet).collect(toList());
assertThat(deletes.size(), is(1));
assertThat(deletes, contains(likeChange().valuesIsEmpty().withOldValues(new Value(existingValue, STRING))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getDeletionsForListReturnsReplacements.
@Test
public void getDeletionsForListReturnsReplacements() throws Exception {
String existingValue1 = "existingValue1";
String existingValue2 = "existingValue2";
Map<Object, Object> replacements = Maps.newHashMap();
replacements.put(NAMES_FIELD, newArrayList());
Map<Object, Object> entity = Maps.newHashMap();
entity.put("replacements", replacements);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
valuesInQuadStore(NAMES_PRED, existingValue1, existingValue2);
List<Change> deletes = instance.getDeletions(dataSet).collect(toList());
assertThat(deletes.size(), is(1));
assertThat(deletes, contains(likeChange().valuesIsEmpty().withOldValues(new Value(existingValue1, STRING), new Value(existingValue2, STRING))));
}
use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value in project timbuctoo by HuygensING.
the class EditMutationChangeLogTest method getAdditionsDoesNotIgnoreAdditionsForSameValue.
// The addition is captured, even though it already exists.
// But this 'addition' is filtered out when the data will be persisted
@Test
public void getAdditionsDoesNotIgnoreAdditionsForSameValue() throws Exception {
String existingValue = "value";
Map<Object, Object> additions = Maps.newHashMap();
additions.put(NAMES_FIELD, newArrayList(createPropertyInput(existingValue)));
Map<Object, Object> entity = Maps.newHashMap();
entity.put("additions", additions);
EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
valuesInQuadStore(NAMES_PRED, existingValue);
List<Change> adds = instance.getAdditions(dataSet).collect(toList());
assertThat(adds.size(), is(1));
assertThat(adds, contains(likeChange().withValues(new Value(existingValue, STRING)).oldValuesIsEmpty()));
}
Aggregations