@Test public void fails_if_changesets_with_same_id_have_different_checksums() throws Exception { Collection<String> errors = validator.validate( singletonList(changeset("identifier", "author", "MATCH m RETURN m")), singletonList(changeset("identifier", "author", "MATCH (m)-->(z) RETURN m, z")) ); assertThat(errors).containsExactly( format( "Changeset with ID <identifier> and author <author> has conflicted checksums.%n" + "\t - Declared: <%s>%n" + "\t - Persisted: <%s>.", checksum(singletonList("MATCH m RETURN m")), checksum(singletonList("MATCH (m)-->(z) RETURN m, z")) ) ); }
public Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { List<Changeset> changesets = declaredChangesets.stream() .filter(RUN_ON_CHANGE.negate()) .collect(Collectors.toList()); return validateChecksums(changesets, persistedChangesets); }
PersistedChangesetValidator { public Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { List<Changeset> changesets = declaredChangesets.stream() .filter(RUN_ON_CHANGE.negate()) .collect(Collectors.toList()); return validateChecksums(changesets, persistedChangesets); } }
PersistedChangesetValidator { public Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { List<Changeset> changesets = declaredChangesets.stream() .filter(RUN_ON_CHANGE.negate()) .collect(Collectors.toList()); return validateChecksums(changesets, persistedChangesets); }  }
PersistedChangesetValidator { public Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { List<Changeset> changesets = declaredChangesets.stream() .filter(RUN_ON_CHANGE.negate()) .collect(Collectors.toList()); return validateChecksums(changesets, persistedChangesets); }  Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets); }
PersistedChangesetValidator { public Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets) { List<Changeset> changesets = declaredChangesets.stream() .filter(RUN_ON_CHANGE.negate()) .collect(Collectors.toList()); return validateChecksums(changesets, persistedChangesets); }  Collection<String> validate(Collection<Changeset> declaredChangesets, Collection<Changeset> persistedChangesets);  }