private static void assertJoinInvalid(DeltaSequence first, DeltaSequence... rest) { try { DeltaSequence.join(first, rest); fail("Expected delta sequence join to fail"); } catch (IllegalArgumentException expected) { } } }
private static void assertJoinInvalid(DeltaSequence first, DeltaSequence... rest) { try { DeltaSequence.join(first, rest); fail("Expected delta sequence join to fail"); } catch (IllegalArgumentException expected) { } } }
/** * Appends the given deltas to the deltas already stored. Updates the latest * snapshot and latest version as well. This method will make a copy of the * snapshot. * * @param updatedSnapshot the snapshot after deltas have been applied * @param newDeltas the deltas that have been applied since the last call to * appendDeltas. */ public void appendDeltas(ReadableWaveletData updatedSnapshot, DeltaSequence newDeltas) { HashedVersion newEndVersion = newDeltas.getEndVersion(); Preconditions.checkArgument( !newDeltas.isEmpty(), "There were no new deltas passed to appendDeltas"); Preconditions.checkArgument(updatedSnapshot.getVersion() == newEndVersion.getVersion(), String.format("Version of snapshot %s doesn't match the HashedVersion %s", updatedSnapshot.getVersion(), newEndVersion)); Preconditions.checkArgument(areContiguousToCurrentVersion(newDeltas), String.format( "Deltas are not contiguous to the current version(%s) %s", getVersionAfterDeltas(), deltas)); WaveletName updatedWaveletName = WaveletDataUtil.waveletNameOf(updatedSnapshot); Preconditions.checkArgument(updatedWaveletName.equals(waveletName), String.format( "Updated wavelet doesn't have the same name as with which this class has been " + "instantiated. %s != %s", updatedWaveletName, waveletName)); // TODO(ljvderijk): This should actually be applying the deltas, however // they do not contain a timestamp at this time. snapshotAfterDeltas = WaveletDataUtil.copyWavelet(updatedSnapshot); deltas = DeltaSequence.join(deltas, newDeltas); }
public void testJoinValidSequencesAllowed() { DeltaSequence s1 = DeltaSequence.of(delta1); DeltaSequence s2 = DeltaSequence.of(delta2, delta3); DeltaSequence joined = DeltaSequence.join(s1, s2); assertEquals(delta1.getAppliedAtVersion(), joined.getStartVersion()); assertEquals(delta3.getResultingVersion(), joined.getEndVersion()); assertEquals(ImmutableList.of(delta1, delta2, delta3), joined); }
public void testJoinValidSequencesAllowed() { DeltaSequence s1 = DeltaSequence.of(delta1); DeltaSequence s2 = DeltaSequence.of(delta2, delta3); DeltaSequence joined = DeltaSequence.join(s1, s2); assertEquals(delta1.getAppliedAtVersion(), joined.getStartVersion()); assertEquals(delta3.getResultingVersion(), joined.getEndVersion()); assertEquals(ImmutableList.of(delta1, delta2, delta3), joined); }