Java Code Examples for com.amazonaws.services.s3.model.PutObjectResult#setVersionId()
The following examples show how to use
com.amazonaws.services.s3.model.PutObjectResult#setVersionId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: S3DataManagerTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 6 votes |
@Test public void testUploadLocalSourceWithNoSSEAlgorithm() throws Exception { File file = new File(mockWorkspaceDir + "/source-file"); FileUtils.write(file, "contents"); PutObjectResult mockedResponse = new PutObjectResult(); mockedResponse.setVersionId("some-version-id"); when(s3Client.putObject(any(PutObjectRequest.class))).thenReturn(mockedResponse); S3DataManager d = new S3DataManager(s3Client, s3InputBucketName, s3InputKeyName, "", file.getPath(), ""); ArgumentCaptor<PutObjectRequest> savedPutObjectRequest = ArgumentCaptor.forClass(PutObjectRequest.class); UploadToS3Output result = d.uploadSourceToS3(listener, testWorkSpace); assertEquals(result.getSourceLocation(), s3InputBucketName + "/" + s3InputKeyName); verify(s3Client).putObject(savedPutObjectRequest.capture()); assertEquals(savedPutObjectRequest.getValue().getBucketName(), s3InputBucketName); assertEquals(savedPutObjectRequest.getValue().getKey(), s3InputKeyName); assertEquals(savedPutObjectRequest.getValue().getMetadata().getContentMD5(), S3DataManager.getZipMD5(file)); assertEquals(savedPutObjectRequest.getValue().getMetadata().getContentLength(), file.length()); assertNull(savedPutObjectRequest.getValue().getMetadata().getSSEAlgorithm()); }
Example 2
Source File: TestPutS3Object.java From nifi with Apache License 2.0 | 6 votes |
private void prepareTest(String filename) { runner.setProperty(PutS3Object.REGION, "ap-northeast-1"); runner.setProperty(PutS3Object.BUCKET, "test-bucket"); runner.assertValid(); Map<String, String> ffAttributes = new HashMap<>(); ffAttributes.put("filename", filename); ffAttributes.put("tagS3PII", "true"); runner.enqueue("Test Content", ffAttributes); PutObjectResult putObjectResult = new PutObjectResult(); putObjectResult.setExpirationTime(new Date()); putObjectResult.setMetadata(new ObjectMetadata()); putObjectResult.setVersionId("test-version"); putObjectResult.setETag("test-etag"); Mockito.when(mockS3Client.putObject(Mockito.any(PutObjectRequest.class))).thenReturn(putObjectResult); MultipartUploadListing uploadListing = new MultipartUploadListing(); Mockito.when(mockS3Client.listMultipartUploads(Mockito.any(ListMultipartUploadsRequest.class))).thenReturn(uploadListing); }
Example 3
Source File: S3DataManagerTest.java From aws-codebuild-jenkins-plugin with Apache License 2.0 | 5 votes |
private S3DataManager createDefaultSource(String localSourcePath, String workspaceSubdir) { this.s3ARNs.put("main", "ARN1/bucket/thing.zip"); //put one item in s3ARNs so exception doesn't happen. PutObjectResult mockedResponse = new PutObjectResult(); mockedResponse.setVersionId("some-version-id"); when(s3Client.putObject(any(PutObjectRequest.class))).thenReturn(mockedResponse); return new S3DataManager(s3Client, s3InputBucketName, s3InputKeyName, sseAlgorithm, localSourcePath, workspaceSubdir); }