use of org.finra.herd.model.dto.S3FileTransferResultsDto in project herd by FINRAOS.
the class S3DaoTest method testUploadFileUseRrs.
/**
* Test that we are able to perform the uploadFile S3Dao operation utilizing Reduced Redundancy Storage (RRS) storage option.
*/
@Test
public void testUploadFileUseRrs() throws IOException, InterruptedException {
// Create local test file.
File targetFile = createLocalFile(localTempPath.toString(), LOCAL_FILE, FILE_SIZE_1_KB);
Assert.assertTrue(targetFile.isFile());
Assert.assertTrue(targetFile.length() == FILE_SIZE_1_KB);
// Upload test file to s3Dao.
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = s3DaoTestHelper.getTestS3FileTransferRequestParamsDto();
s3FileTransferRequestParamsDto.setS3KeyPrefix(TARGET_S3_KEY);
s3FileTransferRequestParamsDto.setLocalPath(targetFile.getPath());
s3FileTransferRequestParamsDto.setUseRrs(true);
S3FileTransferResultsDto results = s3Dao.uploadFile(s3FileTransferRequestParamsDto);
// Validate results.
Assert.assertTrue(results.getTotalFilesTransferred() == 1L);
// Validate the file upload.
s3DaoTestHelper.validateS3FileUpload(s3FileTransferRequestParamsDto, Arrays.asList(TARGET_S3_KEY));
// TODO: Validate Reduced Redundancy Storage (RRS) storage option.
}
use of org.finra.herd.model.dto.S3FileTransferResultsDto in project herd by FINRAOS.
the class S3DaoTest method runUploadFileListTest.
private void runUploadFileListTest() throws IOException, InterruptedException {
// Create local test files.
for (String file : LOCAL_FILES) {
createLocalFile(localTempPath.toString(), file, FILE_SIZE_1_KB);
}
// Create a list of files to be uploaded along with the list of expected S3 key values.
List<File> requestFileList = new ArrayList<>();
List<String> expectedKeys = new ArrayList<>();
for (String file : LOCAL_FILES_SUBSET) {
requestFileList.add(Paths.get(localTempPath.toString(), file).toFile());
expectedKeys.add(TEST_S3_KEY_PREFIX + "/" + file.replaceAll("\\\\", "/"));
}
// Upload test file to s3Dao.
// Since the S3 key prefix represents a directory, we add a trailing '/' character to it.
S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = s3DaoTestHelper.getTestS3FileTransferRequestParamsDto();
s3FileTransferRequestParamsDto.setS3KeyPrefix(TEST_S3_KEY_PREFIX + "/");
s3FileTransferRequestParamsDto.setLocalPath(localTempPath.toString());
s3FileTransferRequestParamsDto.setFiles(requestFileList);
S3FileTransferResultsDto results = s3Dao.uploadFileList(s3FileTransferRequestParamsDto);
// Validate results.
Assert.assertTrue(results.getTotalFilesTransferred() == LOCAL_FILES_SUBSET.size());
// Validate the upload.
s3DaoTestHelper.validateS3FileUpload(s3FileTransferRequestParamsDto, expectedKeys);
}
use of org.finra.herd.model.dto.S3FileTransferResultsDto 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);
}
use of org.finra.herd.model.dto.S3FileTransferResultsDto 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);
}
use of org.finra.herd.model.dto.S3FileTransferResultsDto 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);
}
Aggregations