/** * Create an instance of {@link S3FileCopyRequestParamsDto } * */ public S3FileCopyRequestParamsDto createS3FileCopyRequestParamsDto() { return new S3FileCopyRequestParamsDto(); }
public Object createNewInstance() { return new S3FileCopyRequestParamsDto(); }
/** * Returns a new {@link org.finra.herd.model.dto.S3FileCopyRequestParamsDto} with proxy host and port populated from the configuration. * * @return {@link org.finra.herd.model.dto.S3FileCopyRequestParamsDto} with proxy host and port. */ public S3FileCopyRequestParamsDto getS3FileCopyRequestParamsDto() { S3FileCopyRequestParamsDto params = new S3FileCopyRequestParamsDto(); // Update the parameters with proxy host and port retrieved from the configuration. setProxyHostAndPort(params); return params; }
/** * Returns a new {@link org.finra.herd.model.dto.S3FileCopyRequestParamsDto} with proxy host and port populated from the configuration. * * @return {@link org.finra.herd.model.dto.S3FileCopyRequestParamsDto} with proxy host and port. */ public S3FileCopyRequestParamsDto getS3FileCopyRequestParamsDto() { S3FileCopyRequestParamsDto params = new S3FileCopyRequestParamsDto(); // Update the parameters with proxy host and port retrieved from the configuration. setProxyHostAndPort(params); return params; }
@Override public S3FileCopyRequestParamsDto build() { if (_storedValue == null) { return this.init(new S3FileCopyRequestParamsDto()); } else { return ((S3FileCopyRequestParamsDto) _storedValue); } }
@Test public void testCopyFile() throws InterruptedException { // Create an S3 file copy request parameters DTO. S3FileCopyRequestParamsDto s3FileCopyRequestParamsDto = new S3FileCopyRequestParamsDto(); // Create an S3 file transfer result DTO. S3FileTransferResultsDto s3FileTransferResultsDto = new S3FileTransferResultsDto(); // Mock the external calls. when(s3Dao.copyFile(s3FileCopyRequestParamsDto)).thenReturn(s3FileTransferResultsDto); // Call the method under test. S3FileTransferResultsDto result = s3Service.copyFile(s3FileCopyRequestParamsDto); // Verify the external calls. verify(s3Dao).copyFile(s3FileCopyRequestParamsDto); verifyNoMoreInteractions(s3Dao); // Validate the returned object. assertEquals(s3FileTransferResultsDto, result); }
/** * Test S3 file copy without a KMS ID specified. */ @Test public void testCopyFileNoKmsId() throws InterruptedException { // Put a 1 byte file in S3. s3Operations .putObject(new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, new ByteArrayInputStream(new byte[1]), null), null); // Perform an S3 file copy operation when KMS ID value is not specified. for (String kmsId : Arrays.asList(BLANK_TEXT, null)) { S3FileCopyRequestParamsDto transferDto = new S3FileCopyRequestParamsDto(); transferDto.setSourceBucketName(storageDaoTestHelper.getS3LoadingDockBucketName()); transferDto.setTargetBucketName(storageDaoTestHelper.getS3ExternalBucketName()); transferDto.setSourceObjectKey(TARGET_S3_KEY); transferDto.setTargetObjectKey(TARGET_S3_KEY); transferDto.setKmsKeyId(kmsId); S3FileTransferResultsDto resultsDto = s3Dao.copyFile(transferDto); assertEquals(Long.valueOf(1L), resultsDto.getTotalFilesTransferred()); } }
S3FileCopyRequestParamsDto s3FileCopyRequestParamsDto = new S3FileCopyRequestParamsDto(); s3FileCopyRequestParamsDto.setSourceBucketName("sourceBucketName"); s3FileCopyRequestParamsDto.setSourceObjectKey("sourceObjectKey");
/** * Test S3 file copy without any errors. */ @Test public void testCopyFile() throws InterruptedException { // Put a 1 byte file in S3. s3Operations .putObject(new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, new ByteArrayInputStream(new byte[1]), null), null); S3FileCopyRequestParamsDto transferDto = new S3FileCopyRequestParamsDto(); transferDto.setSourceBucketName(storageDaoTestHelper.getS3LoadingDockBucketName()); transferDto.setTargetBucketName(storageDaoTestHelper.getS3ExternalBucketName()); transferDto.setSourceObjectKey(TARGET_S3_KEY); transferDto.setTargetObjectKey(TARGET_S3_KEY); transferDto.setKmsKeyId(MockS3OperationsImpl.MOCK_KMS_ID); S3FileTransferResultsDto resultsDto = s3Dao.copyFile(transferDto); assertEquals(Long.valueOf(1L), resultsDto.getTotalFilesTransferred()); }
/** * Test S3 file copy with an invalid KMS Id that throws an IllegalStateException because no AmazonServiceException was found. */ @Test public void testCopyFileInvalidKmsIdIllegalStateException() throws InterruptedException { // Put a 1 byte file in S3. s3Operations .putObject(new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, new ByteArrayInputStream(new byte[1]), null), null); try { S3FileCopyRequestParamsDto transferDto = new S3FileCopyRequestParamsDto(); transferDto.setSourceBucketName(storageDaoTestHelper.getS3LoadingDockBucketName()); transferDto.setTargetBucketName(storageDaoTestHelper.getS3ExternalBucketName()); transferDto.setSourceObjectKey(TARGET_S3_KEY); transferDto.setTargetObjectKey(TARGET_S3_KEY); transferDto.setKmsKeyId(MockS3OperationsImpl.MOCK_KMS_ID_FAILED_TRANSFER_NO_EXCEPTION); s3Dao.copyFile(transferDto); fail("An IllegalStateException was expected but not thrown."); } catch (IllegalStateException ex) { assertEquals("Invalid IllegalStateException message returned.", "The transfer operation \"" + MockS3OperationsImpl.MOCK_TRANSFER_DESCRIPTION + "\" failed for an unknown reason.", ex.getMessage()); } }
S3FileCopyRequestParamsDto s3FileCopyRequestParamsDto = new S3FileCopyRequestParamsDto(); s3FileCopyRequestParamsDto.setSourceBucketName("sourceBucketName"); s3FileCopyRequestParamsDto.setSourceObjectKey("sourceObjectKey");
/** * Test S3 file copy with an invalid KMS Id. This should throw an AmazonServiceException. */ @Test public void testCopyFileInvalidKmsId() throws InterruptedException { // Put a 1 byte file in S3. s3Operations .putObject(new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, new ByteArrayInputStream(new byte[1]), null), null); try { S3FileCopyRequestParamsDto transferDto = new S3FileCopyRequestParamsDto(); transferDto.setSourceBucketName(storageDaoTestHelper.getS3LoadingDockBucketName()); transferDto.setTargetBucketName(storageDaoTestHelper.getS3ExternalBucketName()); transferDto.setSourceObjectKey(TARGET_S3_KEY); transferDto.setTargetObjectKey(TARGET_S3_KEY); transferDto.setKmsKeyId(MockS3OperationsImpl.MOCK_KMS_ID_FAILED_TRANSFER); s3Dao.copyFile(transferDto); fail("An AmazonServiceException was expected but not thrown."); } catch (AmazonServiceException ex) { Assert.assertTrue("Invalid AmazonServiceException message returned.", ex.getMessage().contains("Key '" + MockS3OperationsImpl.MOCK_KMS_ID_FAILED_TRANSFER + "' does not exist")); } }
/** * Test S3 file copy with an invalid KMS Id that will result in a cancelled transfer. */ @Test public void testCopyFileInvalidKmsIdCancelled() throws InterruptedException { // Put a 1 byte file in S3. s3Operations .putObject(new PutObjectRequest(storageDaoTestHelper.getS3LoadingDockBucketName(), TARGET_S3_KEY, new ByteArrayInputStream(new byte[1]), null), null); try { S3FileCopyRequestParamsDto transferDto = new S3FileCopyRequestParamsDto(); transferDto.setSourceBucketName(storageDaoTestHelper.getS3LoadingDockBucketName()); transferDto.setTargetBucketName(storageDaoTestHelper.getS3ExternalBucketName()); transferDto.setSourceObjectKey(TARGET_S3_KEY); transferDto.setTargetObjectKey(TARGET_S3_KEY); transferDto.setKmsKeyId(MockS3OperationsImpl.MOCK_KMS_ID_CANCELED_TRANSFER); s3Dao.copyFile(transferDto); fail("An IllegalStateException was expected but not thrown."); } catch (IllegalStateException ex) { assertEquals("Invalid IllegalStateException message returned.", "The transfer operation \"" + MockS3OperationsImpl.MOCK_TRANSFER_DESCRIPTION + "\" did not complete successfully. " + "Current state: \"" + Transfer.TransferState.Canceled + "\".", ex.getMessage()); } }
S3FileCopyRequestParamsDto params = new S3FileCopyRequestParamsDto(); params.setSourceBucketName(completeUploadSingleParamsDto.getSourceBucketName()); params.setTargetBucketName(completeUploadSingleParamsDto.getTargetBucketName());
S3FileCopyRequestParamsDto params = new S3FileCopyRequestParamsDto(); params.setSourceBucketName(completeUploadSingleParamsDto.getSourceBucketName()); params.setTargetBucketName(completeUploadSingleParamsDto.getTargetBucketName());