S3VaultLocation implements VaultLocation { @Override public void upload(final byte[] documentContents) { final PutObjectRequest putObjectRequest = PutObjectRequest.builder() .bucket(bucketName) .key(fileName) .contentType(contentType) .storageClass(StorageClass.REDUCED_REDUNDANCY) .build(); s3Client.putObject(putObjectRequest, RequestBody.fromBytes(documentContents)); }  @Override void upload(final byte[] documentContents); @Override InputStream download(); @Override void clear();  }
@Test void testUpload() throws IOException { underTest.upload(CONTENT); verify(s3Client).putObject(putObjectRequestArgumentCaptor.capture(), requestBodyArgumentCaptor.capture()); final PutObjectRequest putObjectRequest = putObjectRequestArgumentCaptor.getValue(); assertThat(putObjectRequest.bucket(), is(BUCKET_NAME)); assertThat(putObjectRequest.key(), is(FILE_NAME)); assertThat(putObjectRequest.contentType(), is(CONTENT_TYPE)); assertThat(putObjectRequest.storageClass(), is(StorageClass.REDUCED_REDUNDANCY)); final RequestBody requestBody = requestBodyArgumentCaptor.getValue(); assertThat(requestBody.contentStreamProvider().newStream().readAllBytes(), is(CONTENT)); }