use of software.amazon.awssdk.services.s3.model.CopyObjectResponse in project beam by apache.
the class S3FileSystemTest method testAtomicCopy.
private void testAtomicCopy(S3FileSystem s3FileSystem, SSECustomerKey sseCustomerKey) throws IOException {
S3ResourceId sourcePath = S3ResourceId.fromUri(s3FileSystem.getScheme() + "://bucket/from");
S3ResourceId destinationPath = S3ResourceId.fromUri(s3FileSystem.getScheme() + "://bucket/to");
CopyObjectResponse.Builder builder = CopyObjectResponse.builder();
String sseCustomerKeyMd5 = toMd5(sseCustomerKey);
if (sseCustomerKeyMd5 != null) {
builder.sseCustomerKeyMD5(sseCustomerKeyMd5);
}
CopyObjectResponse copyObjectResponse = builder.build();
CopyObjectRequest copyObjectRequest = CopyObjectRequest.builder().copySource(sourcePath.getBucket() + "/" + sourcePath.getKey()).destinationBucket(destinationPath.getBucket()).destinationBucket(destinationPath.getKey()).sseCustomerKey(sseCustomerKey.getKey()).copySourceSSECustomerAlgorithm(sseCustomerKey.getAlgorithm()).build();
when(s3FileSystem.getS3Client().copyObject(any(CopyObjectRequest.class))).thenReturn(copyObjectResponse);
assertEquals(sseCustomerKeyMd5, s3FileSystem.getS3Client().copyObject(copyObjectRequest).sseCustomerKeyMD5());
HeadObjectResponse headObjectResponse = HeadObjectResponse.builder().build();
s3FileSystem.atomicCopy(sourcePath, destinationPath, headObjectResponse);
verify(s3FileSystem.getS3Client(), times(2)).copyObject(any(CopyObjectRequest.class));
}
Aggregations