@Test @SuppressWarnings("resource") public void test_getInputStream() throws Exception { String bucketName = "bucket"; String key = "path/to/foobar"; sut = new S3ObjectResource(amazonS3, bucketName, key); S3ObjectInputStream expected = mock(S3ObjectInputStream.class); S3Object s3Object = mock(S3Object.class); when(s3Object.getObjectContent()).thenReturn(expected); when(amazonS3.getObject(any(GetObjectRequest.class))).thenReturn(s3Object); InputStream actual = sut.getInputStream(); assertThat(actual, is(expected)); verify(amazonS3).getObject(any()); ArgumentCaptor<GetObjectRequest> captor = ArgumentCaptor.forClass(GetObjectRequest.class); verify(amazonS3).getObject(captor.capture()); GetObjectRequest actualRequest = captor.getValue(); assertThat(actualRequest.getBucketName(), is(bucketName)); assertThat(actualRequest.getKey(), is(key)); assertThat(actualRequest.getVersionId(), is(nullValue())); }
@Override public InputStream getInputStream() throws IOException { GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key); versionId.ifPresent(getObjectRequest::setVersionId); return amazonS3.getObject(getObjectRequest).getObjectContent(); }
S3ObjectResource extends AbstractResource implements WritableResource { @Override public InputStream getInputStream() throws IOException { GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key); versionId.ifPresent(getObjectRequest::setVersionId); return amazonS3.getObject(getObjectRequest).getObjectContent(); } }
S3ObjectResource extends AbstractResource implements WritableResource { @Override public InputStream getInputStream() throws IOException { GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key); versionId.ifPresent(getObjectRequest::setVersionId); return amazonS3.getObject(getObjectRequest).getObjectContent(); } S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, TaskExecutor taskExecutor);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, String versionId,
			TaskExecutor taskExecutor);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, Optional<String> versionId);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, String versionId);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key); }
S3ObjectResource extends AbstractResource implements WritableResource { @Override public InputStream getInputStream() throws IOException { GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key); versionId.ifPresent(getObjectRequest::setVersionId); return amazonS3.getObject(getObjectRequest).getObjectContent(); } S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, TaskExecutor taskExecutor);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, String versionId,
			TaskExecutor taskExecutor);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, Optional<String> versionId);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, String versionId);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key); @Override boolean exists(); @Override URL getURL(); @Override File getFile(); @Override long contentLength(); @Override long lastModified(); @Override S3ObjectResource createRelative(String relativePath); @Override String getFilename(); @Override String getDescription(); @Override InputStream getInputStream(); @Override boolean isWritable(); @Override OutputStream getOutputStream(); }
S3ObjectResource extends AbstractResource implements WritableResource { @Override public InputStream getInputStream() throws IOException { GetObjectRequest getObjectRequest = new GetObjectRequest(bucketName, key); versionId.ifPresent(getObjectRequest::setVersionId); return amazonS3.getObject(getObjectRequest).getObjectContent(); } S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, TaskExecutor taskExecutor);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, String versionId,
			TaskExecutor taskExecutor);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, Optional<String> versionId);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key, String versionId);  S3ObjectResource(AmazonS3 amazonS3, String bucketName, String key); @Override boolean exists(); @Override URL getURL(); @Override File getFile(); @Override long contentLength(); @Override long lastModified(); @Override S3ObjectResource createRelative(String relativePath); @Override String getFilename(); @Override String getDescription(); @Override InputStream getInputStream(); @Override boolean isWritable(); @Override OutputStream getOutputStream();  }