AbstractReplicatedLogImpl implements ReplicatedLog { @Override public void snapshotRollback() { snapshottedJournal.addAll(journal); journal = snapshottedJournal; snapshottedJournal = null; snapshotIndex = previousSnapshotIndex; previousSnapshotIndex = -1; snapshotTerm = previousSnapshotTerm; previousSnapshotTerm = -1; } protected  AbstractReplicatedLogImpl(long snapshotIndex, long snapshotTerm,
            List<ReplicatedLogEntry> unAppliedEntries, String logContext); protected  AbstractReplicatedLogImpl(); @Override ReplicatedLogEntry get(long logEntryIndex); @Override ReplicatedLogEntry last(); @Override long lastIndex(); @Override long lastTerm(); @Override long removeFrom(long logEntryIndex); @Override boolean append(ReplicatedLogEntry replicatedLogEntry); @Override void increaseJournalLogCapacity(int amount); @Override List<ReplicatedLogEntry> getFrom(long logEntryIndex); @Override List<ReplicatedLogEntry> getFrom(long logEntryIndex, int maxEntries, long maxDataSize); @Override long size(); @Override int dataSize(); @Override boolean isPresent(long logEntryIndex); @Override boolean isInSnapshot(long logEntryIndex); @Override long getSnapshotIndex(); @Override long getSnapshotTerm(); @Override void setSnapshotIndex(long snapshotIndex); @Override void setSnapshotTerm(long snapshotTerm); @Override void clear(int startIndex, int endIndex); @Override void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm); @Override void snapshotCommit(); @Override void snapshotRollback();  }
@Test public void testSnapshotRollback() { replicatedLogImpl.snapshotPreCommit(1, 1); assertEquals("size", 2, replicatedLogImpl.size()); assertEquals("getSnapshotIndex", 1, replicatedLogImpl.getSnapshotIndex()); assertEquals("getSnapshotTerm", 1, replicatedLogImpl.getSnapshotTerm()); replicatedLogImpl.snapshotRollback(); assertEquals("size", 4, replicatedLogImpl.size()); assertEquals("dataSize", 4, replicatedLogImpl.dataSize()); assertEquals("getSnapshotIndex", -1, replicatedLogImpl.getSnapshotIndex()); assertEquals("getSnapshotTerm", -1, replicatedLogImpl.getSnapshotTerm()); Assert.assertNotNull("get(0)", replicatedLogImpl.get(0)); Assert.assertNotNull("get(3)", replicatedLogImpl.get(3)); }