Search in sources :

Example 16 with EditMutationChangeLog

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

the class EditMutationChangeLogTest method getAdditionsForListReturnsReplacements.

@Test
public void getAdditionsForListReturnsReplacements() throws Exception {
    String addedValue1 = "newValue1";
    String addedValue2 = "newValue2";
    Map<Object, Object> replacements = Maps.newHashMap();
    replacements.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue1), createPropertyInput(addedValue2)));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("replacements", replacements);
    EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
    List<Change> adds = instance.getAdditions(dataSet).collect(toList());
    assertThat(adds.size(), is(1));
    assertThat(adds, contains(likeChange().withValues(new Value(addedValue1, STRING), new Value(addedValue2, STRING)).oldValuesIsEmpty()));
}
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)

Example 17 with EditMutationChangeLog

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

the class EditMutationChangeLogTest method getReplacementsIgnoresReplacementsWithoutValues.

@Test
public void getReplacementsIgnoresReplacementsWithoutValues() throws Exception {
    String addedValue1 = "newValue1";
    String addedValue2 = "newValue2";
    Map<Object, Object> replacements = Maps.newHashMap();
    replacements.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue1), createPropertyInput(addedValue2)));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("replacements", replacements);
    EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
    Stream<Change> reps = instance.getReplacements(dataSet);
    assertThat(reps, 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 18 with EditMutationChangeLog

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

the class EditMutationChangeLogTest method getAdditionsReturnsAdditions.

@Test
public void getAdditionsReturnsAdditions() throws Exception {
    String addedValue = "newValue";
    Map<Object, Object> additions = Maps.newHashMap();
    additions.put(NAMES_FIELD, newArrayList(createPropertyInput(addedValue)));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("additions", additions);
    EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
    List<Change> adds = instance.getAdditions(dataSet).collect(toList());
    assertThat(adds.size(), is(1));
    assertThat(adds, contains(likeChange().withValues(new Value(addedValue, STRING)).oldValuesIsEmpty()));
}
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)

Example 19 with EditMutationChangeLog

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

the class EditMutationChangeLogTest method getAdditionsReturnsReplacements.

@Test
public void getAdditionsReturnsReplacements() throws Exception {
    String addedValue = "newValue";
    Map<Object, Object> replacements = Maps.newHashMap();
    replacements.put(NAMES_FIELD, createPropertyInput(addedValue));
    Map<Object, Object> entity = Maps.newHashMap();
    entity.put("replacements", replacements);
    EditMutationChangeLog instance = new EditMutationChangeLog(new Graph(GRAPH), SUBJECT, entity);
    List<Change> adds = instance.getAdditions(dataSet).collect(toList());
    assertThat(adds.size(), is(1));
    assertThat(adds, contains(likeChange().withValues(new Value(addedValue, STRING)).oldValuesIsEmpty()));
}
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)

Example 20 with EditMutationChangeLog

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

the class EditMutationChangeLogTest method getAdditionsIgnoresReplacementsWithNoValue.

@Test
public void getAdditionsIgnoresReplacementsWithNoValue() throws Exception {
    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);
    Stream<Change> adds = instance.getAdditions(dataSet);
    assertThat(adds, 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)

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