private void validateIteratorSize(CloseableIterator iterator, int expectedSize) {
    try {
      int actualSize = 0;
      while (iterator.hasNext()) {
        iterator.next();
        actualSize++;
      }
      assertEquals("Iterator provided differing number of values", expectedSize, actualSize);
    } finally {
      if (iterator != null) {
        iterator.close();
      }
    }
  }
iterates through and checks against expected size
geode-core/src/integrationTest/java/org/apache/geode/cache/query/internal/index/MapIndexStoreJUnitTest.java