private void mockListStatusIterator(LocalFileSystem mockFs, Path location,
      FileStatus[] fileStatuses) throws IOException {
    when(mockFs.listStatusIterator(location)).thenReturn(
      new RemoteIterator<FileStatus>() {
        private int i = 0;
        @Override
        public boolean hasNext() throws IOException {
          return this.i < fileStatuses.length;
        }
        @Override
        public FileStatus next() throws IOException {
          return fileStatuses[this.i++];
        }
      });
  }
Test counts the number of listStatus calls in the msck core method of
listing sub-directories. This is important to check since it unnecessary
listStatus calls could cause performance degradation in remote filesystems
like S3. The test creates a mock FileSystem object and a mock directory structure
to simulate a table which has 2 partition keys and 2 partition values at each level.
In the end it counts how many times the listStatus is called on the mock filesystem
and confirm its equal to the current theoretical value.

@throws IOException
@throws MetastoreException
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMsckCheckPartitions.java