S3DataTransferer implements DataTransfer { @Override public void deleteProduct(Product product) throws DataTransferException, IOException { for (Reference ref : product.getProductReferences()) { DeleteObjectRequest request = new DeleteObjectRequest(bucketName, stripProtocol( ref.getDataStoreReference(), true)); try { s3Client.deleteObject(request); } catch (AmazonClientException e) { throw new DataTransferException(String.format( "Failed to delete product reference %s from S3", ref.getDataStoreReference()), e); } } } S3DataTransferer(AmazonS3 s3Client, String bucketName, boolean encrypt); @Override void setFileManagerUrl(URL url); @Override void transferProduct(Product product); @Override void retrieveProduct(Product product, File directory); @Override void deleteProduct(Product product);  }
@Test public void testDeleteProduct() throws DataTransferException, IOException { dataTransferer.deleteProduct(product); ArgumentCaptor<DeleteObjectRequest> argument = ArgumentCaptor .forClass(DeleteObjectRequest.class); verify(s3Client).deleteObject(argument.capture()); DeleteObjectRequest request = argument.getValue(); assertThat(request.getBucketName(), is(S3_BUCKET_NAME)); assertThat(request.getKey(), is(EXPECTED_DATA_STORE_REF)); }