Search in sources :

Example 6 with BusinessObjectDefinitionSampleDataFileKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey in project herd by FINRAOS.

the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionSampleFileLowerCaseParameters.

@Test
public void testDownloadBusinessObjectDefinitionSampleFileLowerCaseParameters() {
    // Create and persist a business object definition entity.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectDefinitionServiceTestHelper.getTestSampleDataFiles());
    List<SampleDataFile> sampleFileList = businessObjectDefinitionServiceTestHelper.getTestSampleDataFiles();
    StorageEntity storageEntity = storageDaoHelper.getStorageEntity(STORAGE_NAME);
    storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucketName"));
    storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_DOWNLOAD_ROLE_ARN), "downloadRole"));
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest downloadRequest = new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest();
    BusinessObjectDefinitionSampleDataFileKey sampleDataFileKey = new BusinessObjectDefinitionSampleDataFileKey();
    sampleDataFileKey.setBusinessObjectDefinitionName(BDEF_NAME);
    sampleDataFileKey.setNamespace(NAMESPACE);
    sampleDataFileKey.setDirectoryPath(sampleFileList.get(0).getDirectoryPath());
    sampleDataFileKey.setFileName(sampleFileList.get(0).getFileName());
    // use the lower case name space and business definition still return the same response
    BusinessObjectDefinitionSampleDataFileKey sampleDataFileKeyLowerCase = new BusinessObjectDefinitionSampleDataFileKey();
    sampleDataFileKeyLowerCase.setBusinessObjectDefinitionName(BDEF_NAME.toLowerCase());
    sampleDataFileKeyLowerCase.setNamespace(NAMESPACE.toLowerCase());
    sampleDataFileKeyLowerCase.setDirectoryPath(sampleFileList.get(0).getDirectoryPath());
    sampleDataFileKeyLowerCase.setFileName(sampleFileList.get(0).getFileName());
    downloadRequest.setBusinessObjectDefinitionSampleDataFileKey(sampleDataFileKeyLowerCase);
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse downloadResponse = uploadDownloadService.initiateDownloadSingleSampleFile(downloadRequest);
    assertEquals(downloadResponse.getBusinessObjectDefinitionSampleDataFileKey(), sampleDataFileKey);
    assertNotNull(downloadResponse.getAwsS3BucketName());
    assertNotNull(downloadResponse.getAwsAccessKey());
    assertNotNull(downloadResponse.getAwsSecretKey());
    assertNotNull(downloadResponse.getAwsSessionExpirationTime());
    assertNotNull(downloadResponse.getAwsSessionToken());
    assertNotNull(downloadResponse.getPreSignedUrl());
}
Also used : SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) BusinessObjectDefinitionSampleDataFileKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest) StorageEntity(org.finra.herd.model.jpa.StorageEntity) Test(org.junit.Test)

Example 7 with BusinessObjectDefinitionSampleDataFileKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey in project herd by FINRAOS.

the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionSampleFile.

@Test
public void testDownloadBusinessObjectDefinitionSampleFile() {
    // Create a test storage.
    storageDaoTestHelper.createStorageEntity(STORAGE_NAME, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_DOWNLOAD_ROLE_ARN), DOWNLOADER_ROLE_ARN)));
    // Create and persist a business object definition entity with sample data files.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes(), Arrays.asList(new SampleDataFile(DIRECTORY_PATH, FILE_NAME)));
    // Initiate download of a sample data file.
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest downloadRequest = new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest();
    BusinessObjectDefinitionSampleDataFileKey sampleDataFileKey = new BusinessObjectDefinitionSampleDataFileKey();
    sampleDataFileKey.setNamespace(NAMESPACE);
    sampleDataFileKey.setBusinessObjectDefinitionName(BDEF_NAME);
    sampleDataFileKey.setDirectoryPath(DIRECTORY_PATH);
    sampleDataFileKey.setFileName(FILE_NAME);
    downloadRequest.setBusinessObjectDefinitionSampleDataFileKey(sampleDataFileKey);
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse downloadResponse = uploadDownloadService.initiateDownloadSingleSampleFile(downloadRequest);
    // Validate the response.
    assertNotNull(downloadResponse.getAwsSessionExpirationTime());
    assertNotNull(downloadResponse.getPreSignedUrl());
    assertEquals(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, BDEF_NAME, DIRECTORY_PATH, FILE_NAME), S3_BUCKET_NAME, MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_ACCESS_KEY, MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SECRET_KEY, MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SESSION_TOKEN, downloadResponse.getAwsSessionExpirationTime(), downloadResponse.getPreSignedUrl()), downloadResponse);
}
Also used : SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) BusinessObjectDefinitionSampleDataFileKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest) Attribute(org.finra.herd.model.api.xml.Attribute) Test(org.junit.Test)

Example 8 with BusinessObjectDefinitionSampleDataFileKey

use of org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey in project herd by FINRAOS.

the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionSampleFilesMissingRequiredParameters.

@Test
public void testDownloadBusinessObjectDefinitionSampleFilesMissingRequiredParameters() {
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(null);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A download business object definition sample data file single initiation request must be specified.", e.getMessage());
    }
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(null));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition sample data file key must be specified.", e.getMessage());
    }
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(BLANK_TEXT, BDEF_NAME, DIRECTORY_PATH, FILE_NAME)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, BLANK_TEXT, DIRECTORY_PATH, FILE_NAME)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, BDEF_NAME, BLANK_TEXT, FILE_NAME)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A directory path must be specified.", e.getMessage());
    }
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, BDEF_NAME, DIRECTORY_PATH, BLANK_TEXT)));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A file name must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectDefinitionSampleDataFileKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionSampleDataFileKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey)8 DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest (org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest)7 Test (org.junit.Test)7 DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse (org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse)6 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)5 StorageEntity (org.finra.herd.model.jpa.StorageEntity)4 Attribute (org.finra.herd.model.api.xml.Attribute)2 Credentials (com.amazonaws.services.securitytoken.model.Credentials)1 Date (java.util.Date)1 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)1 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)1 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)1 BusinessObjectDefinitionSampleDataFileEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionSampleDataFileEntity)1