Search in sources :

Example 1 with DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest

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

the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionSampleFileUpperCaseParameters.

@Test
public void testDownloadBusinessObjectDefinitionSampleFileUpperCaseParameters() {
    // 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 sampleDataFileKeyUpperCase = new BusinessObjectDefinitionSampleDataFileKey();
    sampleDataFileKeyUpperCase.setBusinessObjectDefinitionName(BDEF_NAME.toUpperCase());
    sampleDataFileKeyUpperCase.setNamespace(NAMESPACE.toUpperCase());
    sampleDataFileKeyUpperCase.setDirectoryPath(sampleFileList.get(0).getDirectoryPath());
    sampleDataFileKeyUpperCase.setFileName(sampleFileList.get(0).getFileName());
    downloadRequest.setBusinessObjectDefinitionSampleDataFileKey(sampleDataFileKeyUpperCase);
    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 2 with DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest

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

the class UploadDownloadRestControllerTest method testInitiateDownloadSingleSampleFile.

@Test
public void testInitiateDownloadSingleSampleFile() {
    // Create a business object definition sample data file key.
    BusinessObjectDefinitionSampleDataFileKey businessObjectDefinitionSampleDataFileKey = new BusinessObjectDefinitionSampleDataFileKey(BDEF_NAMESPACE, BDEF_NAME, DIRECTORY_PATH, FILE_NAME);
    // Create a request.
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest request = new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(businessObjectDefinitionSampleDataFileKey);
    // Create a response.
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse response = new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse(businessObjectDefinitionSampleDataFileKey, S3_BUCKET_NAME, AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, AWS_ASSUMED_ROLE_SESSION_EXPIRATION_TIME, AWS_PRE_SIGNED_URL);
    // Mock the external calls.
    when(uploadDownloadService.initiateDownloadSingleSampleFile(request)).thenReturn(response);
    // Call the method under test.
    DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse result = uploadDownloadRestController.initiateDownloadSingleSampleFile(request);
    // Verify the external calls.
    verify(uploadDownloadService).initiateDownloadSingleSampleFile(request);
    verifyNoMoreInteractionsHelper();
    // Validate the results.
    assertEquals(response, result);
}
Also used : BusinessObjectDefinitionSampleDataFileKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest) Test(org.junit.Test)

Example 3 with DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest

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

the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionSampleFileTrimmedParameters.

@Test
public void testDownloadBusinessObjectDefinitionSampleFileTrimmedParameters() {
    // 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 sampleDataFileKeyPadded = new BusinessObjectDefinitionSampleDataFileKey();
    sampleDataFileKeyPadded.setBusinessObjectDefinitionName(" " + BDEF_NAME + " ");
    sampleDataFileKeyPadded.setNamespace(" " + NAMESPACE + " ");
    sampleDataFileKeyPadded.setDirectoryPath(sampleFileList.get(0).getDirectoryPath());
    sampleDataFileKeyPadded.setFileName(sampleFileList.get(0).getFileName());
    downloadRequest.setBusinessObjectDefinitionSampleDataFileKey(sampleDataFileKeyPadded);
    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 4 with DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest

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

the class UploadDownloadServiceTest method testDownloadBusinessObjectDefinitionInvalidParameters.

@Test
public void testDownloadBusinessObjectDefinitionInvalidParameters() {
    // 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)));
    // Try to initiate a download using an invalid namespace.
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey("I_DO_NOT_EXIST", BDEF_NAME, DIRECTORY_PATH, FILE_NAME)));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDefinitionServiceTestHelper.getExpectedBusinessObjectDefinitionNotFoundErrorMessage("I_DO_NOT_EXIST", BDEF_NAME), e.getMessage());
    }
    // Try to initiate a download using an invalid business object definition name.
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, "I_DO_NOT_EXIST", DIRECTORY_PATH, FILE_NAME)));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDefinitionServiceTestHelper.getExpectedBusinessObjectDefinitionNotFoundErrorMessage(NAMESPACE, "I_DO_NOT_EXIST"), e.getMessage());
    }
    // Try to initiate a download using an invalid directory path.
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, BDEF_NAME, "I_DO_NOT_EXIST", FILE_NAME)));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Business object definition with name \"%s\" and namespace \"%s\" does not have the specified sample file registered with file name \"%s\" in" + " directory path \"%s\"", BDEF_NAME, NAMESPACE, FILE_NAME, "I_DO_NOT_EXIST"), e.getMessage());
    }
    // Try to initiate a download using an invalid file name.
    try {
        uploadDownloadService.initiateDownloadSingleSampleFile(new DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(new BusinessObjectDefinitionSampleDataFileKey(NAMESPACE, BDEF_NAME, DIRECTORY_PATH, "I_DO_NOT_EXIST")));
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(String.format("Business object definition with name \"%s\" and namespace \"%s\" does not have the specified sample file registered with file name \"%s\" in" + " directory path \"%s\"", BDEF_NAME, NAMESPACE, "I_DO_NOT_EXIST", DIRECTORY_PATH), e.getMessage());
    }
}
Also used : SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) BusinessObjectDefinitionSampleDataFileKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey) DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest(org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest) Attribute(org.finra.herd.model.api.xml.Attribute) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) Test(org.junit.Test)

Example 5 with DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest

use of org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest 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)

Aggregations

BusinessObjectDefinitionSampleDataFileKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionSampleDataFileKey)7 DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest (org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationRequest)7 Test (org.junit.Test)7 DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse (org.finra.herd.model.api.xml.DownloadBusinessObjectDefinitionSampleDataFileSingleInitiationResponse)5 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)5 StorageEntity (org.finra.herd.model.jpa.StorageEntity)3 Attribute (org.finra.herd.model.api.xml.Attribute)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1