SparseJournalIndex implements JournalIndex { @Override public Position lookup(final long index) { final Map.Entry<Long, Integer> entry = positions.floorEntry(index); return entry != null ? new Position(entry.getKey(), entry.getValue()) : null; } SparseJournalIndex(final int density); @Override void index(final Indexed indexedEntry, final int position); @Override Position lookup(final long index); @Override void truncate(final long index); @Override void compact(final long index);  }
@Test public void shouldNotFindIndexWhenNotReachedDensity() { final JournalIndex index = new SparseJournalIndex(5); final Position position = index.lookup(1); assertNull(position); }