Search in sources :

Example 21 with EditMutationChangeLog

use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.EditMutationChangeLog in project timbuctoo by HuygensING.

the class EditMutationChangeLogTest method getDeletionsForListIgnoresReplacementsWithValue.

@Test
public void getDeletionsForListIgnoresReplacementsWithValue() throws Exception {
    String addedValue = "newValue";
    Map<Object, Object> replacements = Maps.newHashMap();
    replacements.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue)));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("replacements", replacements);
    EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
    valuesInQuadStore(NAMES_PRED, addedValue);
    Stream<Change> deletes = instance.getDeletions(dataSet);
    assertThat(deletes, StreamMatchers.empty());
}
Also used : Graph(nl.knaw.huygens.timbuctoo.v5.util.Graph) EditMutationChangeLog(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.EditMutationChangeLog) ChangeMatcher.likeChange(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.ChangeMatcher.likeChange) Test(org.junit.Test)

Example 22 with EditMutationChangeLog

use of nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.EditMutationChangeLog in project timbuctoo by HuygensING.

the class EditMutationChangeLogTest method getReplacementsForSingleValueReturnsReplacementsWithOldValues.

@Test
public void getReplacementsForSingleValueReturnsReplacementsWithOldValues() throws Exception {
    String addedValue1 = "newValue1";
    String oldValue = "oldValue";
    Map<Object, Object> replacements = Maps.newHashMap();
    replacements.put(NAMES_FIELD, createPropertyInput(addedValue1));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("replacements", replacements);
    EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
    valuesInQuadStore(NAMES_PRED, oldValue);
    List<Change> reps = instance.getReplacements(dataSet).collect(toList());
    assertThat(reps.size(), is(1));
    assertThat(reps, contains(likeChange().withValues(new Value(addedValue1, STRING)).withOldValues(new Value(oldValue, STRING))));
}
Also used : Graph(nl.knaw.huygens.timbuctoo.v5.util.Graph) EditMutationChangeLog(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.EditMutationChangeLog) Value(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value) ChangeMatcher.likeChange(nl.knaw.huygens.timbuctoo.v5.graphql.mutations.ChangeMatcher.likeChange) Test(org.junit.Test)

Aggregations

EditMutationChangeLog (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.dto.EditMutationChangeLog)22 Graph (nl.knaw.huygens.timbuctoo.v5.util.Graph)22 Test (org.junit.Test)21 ChangeMatcher.likeChange (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.ChangeMatcher.likeChange)20 Value (nl.knaw.huygens.timbuctoo.v5.graphql.mutations.Change.Value)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 DataSet (nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSet)1 CursorQuad (nl.knaw.huygens.timbuctoo.v5.datastores.quadstore.dto.CursorQuad)1 LogStorageFailedException (nl.knaw.huygens.timbuctoo.v5.filestorage.exceptions.LogStorageFailedException)1 ImmutableContextData (nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.ImmutableContextData)1 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)1