IndexValue getExpectedValue(MockId id, EnumSet<PersistentIndex.IndexEntryType> types, FileSpan fileSpan) {
    if (!allKeys.containsKey(id)) {
      return null;
    }
    TreeSet<IndexValue> indexValues = allKeys.get(id);
    List<IndexValue> toConsider = new ArrayList<>();
    for (IndexValue value : indexValues) {
      if (isWithinFileSpan(value.getOffset(), fileSpan)) {
        toConsider.add(value);
      }
    }

    IndexValue retCandidate = null;
    ListIterator<IndexValue> iterator = toConsider.listIterator(toConsider.size());
    while (iterator.hasPrevious()) {
      IndexValue value = iterator.previous();
      if (types.contains(PersistentIndex.IndexEntryType.DELETE) && value.isDelete()) {
        retCandidate = value;
        break;
      } else if (types.contains(PersistentIndex.IndexEntryType.UNDELETE) && value.isUndelete()) {
        retCandidate = value;
        break;
      } else if (types.contains(PersistentIndex.IndexEntryType.TTL_UPDATE) && !value.isDelete() && !value.isUndelete()
          && value.isTtlUpdate()) {
        retCandidate = value;
        break;
      } else if (types.contains(PersistentIndex.IndexEntryType.PUT) && value.isPut()) {
        retCandidate = value;
        break;
      }
    }

    if (retCandidate != null) {
      IndexValue latest = toConsider.get(toConsider.size() - 1);
      if (latest.getExpiresAtMs() != retCandidate.getExpiresAtMs() || (!retCandidate.isTtlUpdate()
          && latest.isTtlUpdate())) {
        retCandidate = new IndexValue(retCandidate.getOffset().getName(), retCandidate.getBytes(),
            retCandidate.getFormatVersion());
        retCandidate.setFlag(IndexValue.Flags.Ttl_Update_Index);
        retCandidate.setExpiresAtMs(latest.getExpiresAtMs());
      }
    }
    return retCandidate;
  }
Gets the value that is expected to obtained from the {@link PersistentIndex}.
@param id the {@link MockId} whose value is required.
@param types the types of {@link IndexEntry} that are ok to return
@param fileSpan the {@link FileSpan} to search in. Can be {@code null}
@return the value that is expected to obtained from the {@link PersistentIndex}
ambry-store/src/test/java/com/github/ambry/store/CuratedLogIndexState.java