AbstractReplicatedLogImpl implements ReplicatedLog { @Override public boolean isPresent(long logEntryIndex) { if (logEntryIndex > lastIndex()) { return false; } int adjustedIndex = adjustedIndex(logEntryIndex); return adjustedIndex >= 0; } 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 testIsPresent() { assertTrue(replicatedLogImpl.isPresent(0)); assertTrue(replicatedLogImpl.isPresent(1)); assertTrue(replicatedLogImpl.isPresent(2)); assertTrue(replicatedLogImpl.isPresent(3)); replicatedLogImpl.append(new SimpleReplicatedLogEntry(4, 2, new MockPayload("D"))); replicatedLogImpl.snapshotPreCommit(3, 2); replicatedLogImpl.snapshotCommit(); assertFalse(replicatedLogImpl.isPresent(0)); assertFalse(replicatedLogImpl.isPresent(1)); assertFalse(replicatedLogImpl.isPresent(2)); assertFalse(replicatedLogImpl.isPresent(3)); assertTrue(replicatedLogImpl.isPresent(4)); replicatedLogImpl.snapshotPreCommit(4, 2); replicatedLogImpl.snapshotCommit(); assertFalse(replicatedLogImpl.isPresent(4)); replicatedLogImpl.append(new SimpleReplicatedLogEntry(5, 2, new MockPayload("D"))); assertTrue(replicatedLogImpl.isPresent(5)); }