@Override public S3FileTransferResultsDto downloadFile(S3FileTransferRequestParamsDto params) throws InterruptedException { return s3Dao.downloadFile(params); }
@Override public S3FileTransferResultsDto downloadFile(S3FileTransferRequestParamsDto params) throws InterruptedException { return s3Dao.downloadFile(params); }
@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); }
/** * Test that we are able to perform the uploadFile S3Dao operation on S3 using our DAO tier. */ @Test public void testDownloadFile() throws IOException, InterruptedException { // Upload local file to s3Dao. testUploadFile(); // Clean up the local directory, so we can test the download. FileUtils.deleteDirectory(localTempPath.toFile()); // Create local temp directory - this also validates that clean up was really executed. Assert.assertTrue(localTempPath.toFile().mkdir()); // Destination local file. File destinationLocalFile = Paths.get(localTempPath.toString(), LOCAL_FILE).toFile(); // Execute download. S3FileTransferRequestParamsDto s3FileTransferRequestParamsDto = s3DaoTestHelper.getTestS3FileTransferRequestParamsDto(); s3FileTransferRequestParamsDto.setS3KeyPrefix(TARGET_S3_KEY); s3FileTransferRequestParamsDto.setLocalPath(destinationLocalFile.getPath()); S3FileTransferResultsDto results = s3Dao.downloadFile(s3FileTransferRequestParamsDto); // Validate results. Assert.assertTrue(results.getTotalFilesTransferred() == 1L); // Validate that we have the file downloaded from S3. Assert.assertTrue(destinationLocalFile.isFile()); }