S3SingleFileExplorer extends S3FileExplorer { @Override public void addToBuilder(final FileList.Builder builder) { final GetObjectMetadataRequest objectMetadataRequest = new GetObjectMetadataRequest(bucketName, path); final ObjectMetadata objectMetadata = new DefaultRetryable<ObjectMetadata>("Looking up for a single object") { @Override public ObjectMetadata call() { return s3Client.getObjectMetadata(objectMetadataRequest); } }.executeWith(retryExecutor); builder.add(path, objectMetadata.getContentLength()); } S3SingleFileExplorer(final String bucket, final AmazonS3 client, final RetryExecutor retryExecutor, final String path); @Override void addToBuilder(final FileList.Builder builder);  }
@Test public void addToBuilder_should_request_single_object_metadata() { when(s3Client.getObjectMetadata(any(GetObjectMetadataRequest.class))).thenReturn(metadata); when(metadata.getContentLength()).thenReturn(1L); s3SingleFileExplorer.addToBuilder(builder); verify(builder).add(PATH, 1); }