S3MultipartUpload { void complete(String uploadId, List<PartETag> partETags) { CompleteMultipartUploadRequest request = new CompleteMultipartUploadRequest(bucket, key, uploadId, partETags); s3.completeMultipartUpload(request); if (stopwatch.isRunning()) { stopwatch.stop(); } long seconds = stopwatch.elapsed(SECONDS); log.info("Successfully uploaded {} bytes in {} seconds ({} bps) to s3: (float) bytes / seconds, bucket, key); }    }
@Test public void complete() { InitiateMultipartUploadResult response = mock(InitiateMultipartUploadResult.class); when(response.getUploadId()).thenReturn(UPLOAD_ID); when(s3.initiateMultipartUpload(any(InitiateMultipartUploadRequest.class))).thenReturn(response); ArgumentCaptor<CompleteMultipartUploadRequest> request = ArgumentCaptor .forClass(CompleteMultipartUploadRequest.class); @SuppressWarnings("unchecked") List<PartETag> partETags = mock(List.class); when(s3.completeMultipartUpload(request.capture())).thenReturn(null); underTest.start(); underTest.complete(UPLOAD_ID, partETags); assertThat(request.getValue().getBucketName(), is(BUCKET)); assertThat(request.getValue().getKey(), is(KEY)); assertThat(request.getValue().getUploadId(), is(UPLOAD_ID)); assertThat(request.getValue().getPartETags(), is(partETags)); }