@Override
  public synchronized List<DatasetVersionRecord> getAllValidVersionsOutOfRetentionCount(String accountName,
      String containerName, String datasetName) throws AccountServiceException {
    List<DatasetVersionRecord> datasetVersionRecordList = new ArrayList<>();
    Account account = nameToAccountMap.get(accountName);
    short accountId = account.getId();
    short containerId = account.getContainerByName(containerName).getId();
    Dataset dataset = getDataset(accountName, containerName, datasetName);
    Integer retentionCount = dataset.getRetentionCount();
    if (retentionCount != null && idToDatasetVersionMap.get(new Pair<>(accountId, containerId)) != null) {
      List<Map.Entry<Pair<String, String>, DatasetVersionRecord>> datasetToDatasetVersionList =
          new ArrayList<>(idToDatasetVersionMap.get(new Pair<>(accountId, containerId)).entrySet());
      datasetToDatasetVersionList.sort(
          (entry1, entry2) -> entry2.getValue().getVersion().compareTo(entry1.getValue().getVersion()));
      for (Map.Entry<Pair<String, String>, DatasetVersionRecord> entry : datasetToDatasetVersionList) {
        retentionCount--;
        if (retentionCount >= 0) {
          continue;
        }
        Pair<String, String> key = entry.getKey();
        if (key.getFirst().equals(datasetName)) {
          datasetVersionRecordList.add(entry.getValue());
        }
      }
    }
    return datasetVersionRecordList;
  }
Constructor.
@param shouldReturnOnlyUnknown {@code true} if always returns {@link InMemAccountService#UNKNOWN_ACCOUNT} when queried
                                                    by account name; {@code false} to do the actual query.
@param notifyConsumers {@code true} if consumers should be notified of account changes. {@code false} otherwise.
ambry-test-utils/src/main/java/com/github/ambry/account/InMemAccountService.java