Search in sources :

Example 76 with S3FileTransferRequestParamsDto

use of org.finra.herd.model.dto.S3FileTransferRequestParamsDto in project herd by FINRAOS.

the class S3ServiceTest method testUploadFile.

@Test
public void testUploadFile() throws InterruptedException {
    // Create an S3 file transfer request parameters DTO.
    S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
    // Create an S3 file transfer result DTO.
    S3FileTransferResultsDto s3FileTransferResultsDto = new S3FileTransferResultsDto();
    // Mock the external calls.
    when(s3Dao.uploadFile(s3FileTransferRequestParamsDto)).thenReturn(s3FileTransferResultsDto);
    // Call the method under test.
    S3FileTransferResultsDto result = s3Service.uploadFile(s3FileTransferRequestParamsDto);
    // Verify the external calls.
    verify(s3Dao).uploadFile(s3FileTransferRequestParamsDto);
    verifyNoMoreInteractions(s3Dao);
    // Validate the returned object.
    assertEquals(s3FileTransferResultsDto, result);
}
Also used : S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) S3FileTransferResultsDto(org.finra.herd.model.dto.S3FileTransferResultsDto) Test(org.junit.Test)

Example 77 with S3FileTransferRequestParamsDto

use of org.finra.herd.model.dto.S3FileTransferRequestParamsDto in project herd by FINRAOS.

the class S3ServiceTest method testTagObjects.

@Test
public void testTagObjects() {
    // Create an S3 file transfer request parameters DTO to access S3 objects.
    S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
    s3FileTransferRequestParamsDto.setFiles(Arrays.asList(new File(TEST_S3_KEY_PREFIX + "/" + LOCAL_FILE)));
    // Create an S3 file transfer request parameters DTO to tag S3 objects.
    S3FileTransferRequestParamsDto s3ObjectTaggerParamsDto = new S3FileTransferRequestParamsDto();
    s3ObjectTaggerParamsDto.setAwsAccessKeyId(AWS_ASSUMED_ROLE_ACCESS_KEY);
    s3ObjectTaggerParamsDto.setAwsSecretKey(AWS_ASSUMED_ROLE_SECRET_KEY);
    s3ObjectTaggerParamsDto.setSessionToken(AWS_ASSUMED_ROLE_SESSION_TOKEN);
    // Create an S3 object tag.
    Tag tag = new Tag(S3_OBJECT_TAG_KEY, S3_OBJECT_TAG_VALUE);
    // Call the method under test.
    s3Service.tagObjects(s3FileTransferRequestParamsDto, s3ObjectTaggerParamsDto, tag);
    // Verify the external calls.
    verify(s3Dao).tagObjects(s3FileTransferRequestParamsDto, s3ObjectTaggerParamsDto, tag);
    verifyNoMoreInteractions(s3Dao);
}
Also used : S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) Tag(com.amazonaws.services.s3.model.Tag) File(java.io.File) Test(org.junit.Test)

Example 78 with S3FileTransferRequestParamsDto

use of org.finra.herd.model.dto.S3FileTransferRequestParamsDto in project herd by FINRAOS.

the class S3ServiceTest method testUploadFileList.

@Test
public void testUploadFileList() throws InterruptedException {
    // Create an S3 file transfer request parameters DTO.
    S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
    // Create an S3 file transfer result DTO.
    S3FileTransferResultsDto s3FileTransferResultsDto = new S3FileTransferResultsDto();
    // Mock the external calls.
    when(s3Dao.uploadFileList(s3FileTransferRequestParamsDto)).thenReturn(s3FileTransferResultsDto);
    // Call the method under test.
    S3FileTransferResultsDto result = s3Service.uploadFileList(s3FileTransferRequestParamsDto);
    // Verify the external calls.
    verify(s3Dao).uploadFileList(s3FileTransferRequestParamsDto);
    verifyNoMoreInteractions(s3Dao);
    // Validate the returned object.
    assertEquals(s3FileTransferResultsDto, result);
}
Also used : S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) S3FileTransferResultsDto(org.finra.herd.model.dto.S3FileTransferResultsDto) Test(org.junit.Test)

Example 79 with S3FileTransferRequestParamsDto

use of org.finra.herd.model.dto.S3FileTransferRequestParamsDto in project herd by FINRAOS.

the class S3ServiceTest method testDownloadFile.

@Test
public void testDownloadFile() throws InterruptedException {
    // Create an S3 file transfer request parameters DTO.
    S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
    // Create an S3 file transfer result DTO.
    S3FileTransferResultsDto s3FileTransferResultsDto = new S3FileTransferResultsDto();
    // Mock the external calls.
    when(s3Dao.downloadFile(s3FileTransferRequestParamsDto)).thenReturn(s3FileTransferResultsDto);
    // Call the method under test.
    S3FileTransferResultsDto result = s3Service.downloadFile(s3FileTransferRequestParamsDto);
    // Verify the external calls.
    verify(s3Dao).downloadFile(s3FileTransferRequestParamsDto);
    verifyNoMoreInteractions(s3Dao);
    // Validate the returned object.
    assertEquals(s3FileTransferResultsDto, result);
}
Also used : S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) S3FileTransferResultsDto(org.finra.herd.model.dto.S3FileTransferResultsDto) Test(org.junit.Test)

Example 80 with S3FileTransferRequestParamsDto

use of org.finra.herd.model.dto.S3FileTransferRequestParamsDto in project herd by FINRAOS.

the class S3ServiceTest method testValidateGlacierS3FilesRestored.

@Test
public void testValidateGlacierS3FilesRestored() throws RuntimeException {
    // Create an S3 file transfer request parameters DTO.
    S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = new S3FileTransferRequestParamsDto();
    // Call the method under test.
    s3Service.validateGlacierS3FilesRestored(s3FileTransferRequestParamsDto);
    // Verify the external calls.
    verify(s3Dao).validateGlacierS3FilesRestored(s3FileTransferRequestParamsDto);
    verifyNoMoreInteractions(s3Dao);
}
Also used : S3FileTransferRequestParamsDto(org.finra.herd.model.dto.S3FileTransferRequestParamsDto) Test(org.junit.Test)

Aggregations

S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)160 Test (org.junit.Test)119 File (java.io.File)41 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)31 ByteArrayInputStream (java.io.ByteArrayInputStream)30 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)27 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)23 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)23 S3FileTransferResultsDto (org.finra.herd.model.dto.S3FileTransferResultsDto)23 IOException (java.io.IOException)21 AmazonServiceException (com.amazonaws.AmazonServiceException)20 MultiObjectDeleteException (com.amazonaws.services.s3.model.MultiObjectDeleteException)20 InvocationOnMock (org.mockito.invocation.InvocationOnMock)20 AmazonClientException (com.amazonaws.AmazonClientException)19 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)19 ArrayList (java.util.ArrayList)19 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)18 Tag (com.amazonaws.services.s3.model.Tag)16 StorageFile (org.finra.herd.model.api.xml.StorageFile)15 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)14