Search in sources :

Example 11 with RegServerAccessParamsDto

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

the class UploaderControllerTest method testPerformUploadManifestContainsDuplicateFileNames.

@Test(expected = IllegalArgumentException.class)
public void testPerformUploadManifestContainsDuplicateFileNames() throws Exception {
    List<ManifestFile> duplicateTestDataFiles = new ArrayList<>();
    duplicateTestDataFiles.addAll(testManifestFiles);
    duplicateTestDataFiles.add(testManifestFiles.get(0));
    // Create local data files in LOCAL_TEMP_PATH_INPUT directory
    for (ManifestFile manifestFile : testManifestFiles) {
        createLocalFile(LOCAL_TEMP_PATH_INPUT.toString(), manifestFile.getFileName(), FILE_SIZE_1_KB);
    }
    // Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory
    UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
    uploaderInputManifestDto.setManifestFiles(duplicateTestDataFiles);
    File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto);
    Assert.assertTrue(manifestFile.isFile());
    // Try to upload business object data having duplicate file names.
    RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true).withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build();
    uploaderController.performUpload(regServerAccessParamsDto, manifestFile, getTestS3FileTransferRequestParamsDto(), false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS);
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) ArrayList(java.util.ArrayList) RegServerAccessParamsDto(org.finra.herd.model.dto.RegServerAccessParamsDto) File(java.io.File) ManifestFile(org.finra.herd.model.dto.ManifestFile) ManifestFile(org.finra.herd.model.dto.ManifestFile) Test(org.junit.Test)

Example 12 with RegServerAccessParamsDto

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

the class UploaderControllerTest method testPerformUploadManifestFileNameDoesNotMatchActualFileName.

@Test(expected = IllegalArgumentException.class)
public void testPerformUploadManifestFileNameDoesNotMatchActualFileName() throws Exception {
    List<ManifestFile> declaredManifestFiles = getManifestFilesFromFileNames(Arrays.asList("test-data-1.txt", "test-data-2.txt"), FILE_SIZE_1_KB);
    List<ManifestFile> actualManifestFiles = getManifestFilesFromFileNames(Arrays.asList("test-data-1.txt", "TEST-DATA-2.TXT"), FILE_SIZE_1_KB);
    // Create local data files in LOCAL_TEMP_PATH_INPUT directory
    for (ManifestFile manifestFile : actualManifestFiles) {
        createLocalFile(LOCAL_TEMP_PATH_INPUT.toString(), manifestFile.getFileName(), FILE_SIZE_1_KB);
    }
    // Create uploader input manifest file in LOCAL_TEMP_PATH_INPUT directory.
    UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
    uploaderInputManifestDto.setManifestFiles(declaredManifestFiles);
    File manifestFile = createManifestFile(LOCAL_TEMP_PATH_INPUT.toString(), uploaderInputManifestDto);
    Assert.assertTrue(manifestFile.isFile());
    // Try to upload business object data with one of the file having name that does not match to incorrect name specified.
    RegServerAccessParamsDto regServerAccessParamsDto = RegServerAccessParamsDto.builder().withRegServerHost(WEB_SERVICE_HOSTNAME).withRegServerPort(WEB_SERVICE_HTTPS_PORT).withUseSsl(true).withUsername(WEB_SERVICE_HTTPS_USERNAME).withPassword(WEB_SERVICE_HTTPS_PASSWORD).build();
    uploaderController.performUpload(regServerAccessParamsDto, manifestFile, getTestS3FileTransferRequestParamsDto(), false, false, TEST_RETRY_ATTEMPTS, TEST_RETRY_DELAY_SECS);
}
Also used : UploaderInputManifestDto(org.finra.herd.model.dto.UploaderInputManifestDto) RegServerAccessParamsDto(org.finra.herd.model.dto.RegServerAccessParamsDto) File(java.io.File) ManifestFile(org.finra.herd.model.dto.ManifestFile) ManifestFile(org.finra.herd.model.dto.ManifestFile) Test(org.junit.Test)

Example 13 with RegServerAccessParamsDto

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

the class UploaderWebClientTest method testWebClientRegServerAccessParamsDtoSetterAndGetter.

@Test
public void testWebClientRegServerAccessParamsDtoSetterAndGetter() {
    // Create and initialize an instance of RegServerAccessParamsDto.
    RegServerAccessParamsDto regServerAccessParamsDto = new RegServerAccessParamsDto();
    regServerAccessParamsDto.setRegServerHost(WEB_SERVICE_HOSTNAME);
    regServerAccessParamsDto.setRegServerPort(WEB_SERVICE_HTTPS_PORT);
    regServerAccessParamsDto.setUseSsl(true);
    regServerAccessParamsDto.setUsername(WEB_SERVICE_HTTPS_USERNAME);
    regServerAccessParamsDto.setPassword(WEB_SERVICE_HTTPS_PASSWORD);
    // Set the DTO.
    uploaderWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto);
    // Retrieve the DTO and validate the results.
    RegServerAccessParamsDto resultRegServerAccessParamsDto = uploaderWebClient.getRegServerAccessParamsDto();
    // validate the results.
    assertEquals(WEB_SERVICE_HOSTNAME, resultRegServerAccessParamsDto.getRegServerHost());
    assertEquals(WEB_SERVICE_HTTPS_PORT, resultRegServerAccessParamsDto.getRegServerPort());
    assertTrue(resultRegServerAccessParamsDto.isUseSsl());
    assertEquals(WEB_SERVICE_HTTPS_USERNAME, resultRegServerAccessParamsDto.getUsername());
    assertEquals(WEB_SERVICE_HTTPS_PASSWORD, resultRegServerAccessParamsDto.getPassword());
}
Also used : RegServerAccessParamsDto(org.finra.herd.model.dto.RegServerAccessParamsDto) Test(org.junit.Test)

Example 14 with RegServerAccessParamsDto

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

the class RetentionExpirationExporterControllerTest method testPerformDownloadOutputFileAlreadyExist.

@Test
public void testPerformDownloadOutputFileAlreadyExist() throws Exception {
    File outputFile = new File(LOCAL_OUTPUT_FILE);
    // Create an output file to test file already exists.
    assertTrue(outputFile.createNewFile());
    // Try to perform the retention expiration export.
    try {
        retentionExpirationExporterController.performRetentionExpirationExport(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME, outputFile, new RegServerAccessParamsDto(), UDC_SERVICE_HOSTNAME);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("The specified local output file \"%s\" already exists.", outputFile.toString()), e.getMessage());
    }
}
Also used : RegServerAccessParamsDto(org.finra.herd.model.dto.RegServerAccessParamsDto) File(java.io.File) Test(org.junit.Test)

Example 15 with RegServerAccessParamsDto

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

the class DataBridgeWebClientTest method before.

@Before
public void before() {
    dataBridgeWebClient = new DataBridgeWebClient() {
    };
    RegServerAccessParamsDto regServerAccessParamsDto = new RegServerAccessParamsDto();
    regServerAccessParamsDto.setUseSsl(false);
    regServerAccessParamsDto.setRegServerPort(8080);
    dataBridgeWebClient.setRegServerAccessParamsDto(regServerAccessParamsDto);
    dataBridgeWebClient.httpClientOperations = httpClientOperations;
    dataBridgeWebClient.herdStringHelper = herdStringHelper;
}
Also used : RegServerAccessParamsDto(org.finra.herd.model.dto.RegServerAccessParamsDto) Before(org.junit.Before)

Aggregations

RegServerAccessParamsDto (org.finra.herd.model.dto.RegServerAccessParamsDto)24 Test (org.junit.Test)13 File (java.io.File)12 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)9 Before (org.junit.Before)5 ManifestFile (org.finra.herd.model.dto.ManifestFile)4 ApplicationContext (org.springframework.context.ApplicationContext)4 Path (java.nio.file.Path)3 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)3 S3KeyPrefixInformation (org.finra.herd.model.api.xml.S3KeyPrefixInformation)3 Storage (org.finra.herd.model.api.xml.Storage)3 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)3 DownloaderInputManifestDto (org.finra.herd.model.dto.DownloaderInputManifestDto)3 S3FileTransferResultsDto (org.finra.herd.model.dto.S3FileTransferResultsDto)3 UploaderInputManifestDto (org.finra.herd.model.dto.UploaderInputManifestDto)3 S3Service (org.finra.herd.service.S3Service)3 BusinessObjectDataHelper (org.finra.herd.service.helper.BusinessObjectDataHelper)3 StorageFileHelper (org.finra.herd.service.helper.StorageFileHelper)3 StorageHelper (org.finra.herd.service.helper.StorageHelper)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3