private void doGetEntriesSinceTest(NavigableMap<MockId, NavigableSet<IndexValue>> referenceIndex,
      IndexSegment segment, MockId idToCheck, long maxSize, long existingSize, MockId highestExpectedId)
      throws StoreException {
    // test getEntriesSince
    FindEntriesCondition condition = new FindEntriesCondition(maxSize);

    List<MessageInfo> entries = new ArrayList<>();
    assertEquals("Unexpected return value from getEntriesSince()", highestExpectedId != null,
        segment.getEntriesSince(idToCheck, condition, entries, new AtomicLong(existingSize), false));
    if (highestExpectedId != null) {
      assertEquals("Highest ID not as expected", highestExpectedId, entries.get(entries.size() - 1).getStoreKey());
      MockId nextExpectedId = idToCheck == null ? referenceIndex.firstKey() : referenceIndex.higherKey(idToCheck);
      for (MessageInfo info : entries) {
        assertEquals("Entry is unexpected", nextExpectedId, info.getStoreKey());
        nextExpectedId = referenceIndex.higherKey(nextExpectedId);
      }
    } else {
      assertEquals("Entries list is not empty", 0, entries.size());
    }

    // test getIndexEntriesSince()
    for (boolean oneEntryPerKey : new boolean[]{true, false}) {
      List<IndexEntry> indexEntries = new ArrayList<>();
      assertEquals("Unexpected return value from getIndexEntriesSince()", highestExpectedId != null,
          segment.getIndexEntriesSince(idToCheck, condition, indexEntries, new AtomicLong(existingSize), oneEntryPerKey,
              false));
      if (highestExpectedId != null) {
        assertEquals("Highest ID not as expected", highestExpectedId,
            indexEntries.get(indexEntries.size() - 1).getKey());
        MockId nextExpectedId = idToCheck == null ? referenceIndex.firstKey() : referenceIndex.higherKey(idToCheck);
        // gather all index entries that should be there
        final List<IndexEntry> expectedEntries = new ArrayList<>();
        while (nextExpectedId != null) {
          NavigableSet<IndexValue> values = referenceIndex.get(nextExpectedId);
          if (oneEntryPerKey) {
            IndexValue value = values.last();
            if (values.size() > 1 && !value.isDelete() && value.isTtlUpdate()) {
              value = values.first();
            }
            expectedEntries.add(new IndexEntry(nextExpectedId, value));
          } else {
            for (IndexValue value : values) {
              expectedEntries.add(new IndexEntry(nextExpectedId, value));
            }
          }
          if (nextExpectedId.equals(highestExpectedId)) {
            break;
          }
          nextExpectedId = referenceIndex.higherKey(nextExpectedId);
        }
        assertEquals("Number of entries not as expected", expectedEntries.size(), indexEntries.size());
        Iterator<IndexEntry> it = indexEntries.iterator();
        for (IndexEntry expected : expectedEntries) {
          assertTrue("There should be more entries", it.hasNext());
          IndexEntry actual = it.next();
          assertEquals("Key not as expected", expected.getKey(), actual.getKey());
          assertEquals("Value not as expected", expected.getValue().getBytes(), actual.getValue().getBytes());
        }
      } else {
        assertEquals("Entries list is not empty", 0, indexEntries.size());
      }
    }
  }
Does the {@link IndexSegment#getEntriesSince(StoreKey, FindEntriesCondition, List, AtomicLong, boolean)} and checks that
all the returned entries are as expected and that all the entries expected have been returned.
@param referenceIndex the index entries to be used as reference.
@param segment the {@link IndexSegment} to test
@param idToCheck the {@link MockId} to check.
@param maxSize the parameter for {@link FindEntriesCondition#FindEntriesCondition(long)}.
@param existingSize the third parameter for getEntriesSince().
@param highestExpectedId the highest expected Id in the returned entries.
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/IndexSegmentTest.java