### Question:
InterleavedLedgerStorage implements CompactableLedgerStorage, EntryLogListener { public LedgerCache.PageEntriesIterable getIndexEntries(long ledgerId) throws IOException { return ledgerCache.listEntries(ledgerId); } @VisibleForTesting  InterleavedLedgerStorage(); @Override void initialize(ServerConfiguration conf,
                           LedgerManager ledgerManager,
                           LedgerDirsManager ledgerDirsManager,
                           LedgerDirsManager indexDirsManager,
                           StateManager stateManager,
                           CheckpointSource checkpointSource,
                           Checkpointer checkpointer,
                           StatsLogger statsLogger,
                           ByteBufAllocator allocator); @VisibleForTesting void initializeWithEntryLogger(ServerConfiguration conf,
                LedgerManager ledgerManager,
                LedgerDirsManager ledgerDirsManager,
                LedgerDirsManager indexDirsManager,
                StateManager stateManager,
                CheckpointSource checkpointSource,
                Checkpointer checkpointer,
                EntryLogger entryLogger,
                StatsLogger statsLogger); @Override void forceGC(); @Override boolean isInForceGC(); @Override void start(); @Override void shutdown(); @Override boolean setFenced(long ledgerId); @Override boolean isFenced(long ledgerId); @Override void setExplicitlac(long ledgerId, ByteBuf lac); @Override ByteBuf getExplicitLac(long ledgerId); @Override void setMasterKey(long ledgerId, byte[] masterKey); @Override byte[] readMasterKey(long ledgerId); @Override boolean ledgerExists(long ledgerId); @Override long getLastAddConfirmed(long ledgerId); @Override boolean waitForLastAddConfirmedUpdate(long ledgerId,
                                                 long previousLAC,
                                                 Watcher<LastAddConfirmedUpdateNotification> watcher); @Override void cancelWaitForLastAddConfirmedUpdate(long ledgerId,
                                                    Watcher<LastAddConfirmedUpdateNotification> watcher); @Override long addEntry(ByteBuf entry); @Override ByteBuf getEntry(long ledgerId, long entryId); @Override void checkpoint(Checkpoint checkpoint); @Override synchronized void flush(); @Override void deleteLedger(long ledgerId); @Override Iterable<Long> getActiveLedgersInRange(long firstLedgerId, long lastLedgerId); @Override void updateEntriesLocations(Iterable<EntryLocation> locations); @Override void flushEntriesLocationsIndex(); @Override EntryLogger getEntryLogger(); @Override void registerLedgerDeletionListener(LedgerDeletionListener listener); @Override void onRotateEntryLog(); LedgerCache.PageEntriesIterable getIndexEntries(long ledgerId); LedgerCache.LedgerIndexMetadata readLedgerIndexMetadata(long ledgerId); @Override List<DetectedInconsistency> localConsistencyCheck(Optional<RateLimiter> rateLimiter); @Override List<GarbageCollectionStatus> getGarbageCollectionStatus(); @Override OfLong getListOfEntriesOfLedger(long ledgerId); static final long INVALID_ENTRYID; }### Answer:
@Test public void testIndexEntryIterator() throws Exception { try (LedgerCache.PageEntriesIterable pages = interleavedStorage.getIndexEntries(0)) { MutableLong curEntry = new MutableLong(0); for (LedgerCache.PageEntries page : pages) { try (LedgerEntryPage lep = page.getLEP()) { lep.getEntries((entry, offset) -> { Assert.assertEquals(curEntry.longValue(), entry); Assert.assertNotEquals(0, offset); curEntry.setValue(entriesPerWrite + entry); return true; }); } } Assert.assertEquals(entriesPerWrite * numWrites, curEntry.longValue()); } }