### Question:
S3FileSystemProvider implements FileSystemProvider { @Nonnull @Override public List<DataSetFile> listFiles(@Nonnull final Path path, @Nonnull final Configuration conf) { final AmazonS3 s3 = createS3Client(path.toUri(), conf); try { return s3.listBuckets().stream() .map(bucket -> { final DataSetFile file = new DataSetFile(); file.setName(bucket.getName()); file.setDirectory(true); file.setModificationTime(bucket.getCreationDate().getTime()); file.setPath(path.toUri().getScheme() + ": return file; }) .collect(Collectors.toList()); } finally { if (s3 instanceof AmazonS3Client) { ((AmazonS3Client) s3).shutdown(); } } }  @Nonnull @Override List<DataSetFile> listFiles(@Nonnull final Path path, @Nonnull final Configuration conf); @Override boolean supportsPath(@Nonnull final Path path);  }### Answer:
@Test @SuppressWarnings("unchecked") public void listFiles() { final AmazonS3 client = Mockito.mock(AmazonS3.class); final Bucket bucket1 = createBucket("bucket1"); final Bucket bucket2 = createBucket("bucket2"); Mockito.when(client.listBuckets()).thenReturn(Arrays.asList(bucket1, bucket2)); final S3FileSystemProvider provider = new S3FileSystemProvider() { @Override protected AmazonS3 createS3Client(@Nonnull final URI uri, @Nonnull final Configuration conf) { return client; } }; final List<DataSetFile> files = provider.listFiles(new Path(S3N), new Configuration(false)); Assert.assertThat(files, CoreMatchers.hasItems(isDataSetFile(bucket1), isDataSetFile(bucket2))); Assert.assertEquals(2, files.size()); }