Search in sources :

Example 1 with UploadBusinessObjectDefinitionSampleDataFileInitiationRequest

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

the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFile.

@Test
public void testUploadBusinessObjectDefinitionSampleFile() {
    String s3_velocity_template = "$namespace/$businessObjectDefinitionName";
    String expectedS3Keyprefix = NAMESPACE.toLowerCase() + "/" + BDEF_NAME.toLowerCase() + "/";
    expectedS3Keyprefix = expectedS3Keyprefix.replace("_", "-");
    // Create a test storage.
    storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), UPLOADER_ROLE_ARN), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), s3_velocity_template)));
    // 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());
    UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest();
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    request.setBusinessObjectDefinitionKey(businessObjectDefinitionKey);
    UploadBusinessObjectDefinitionSampleDataFileInitiationResponse response = uploadDownloadService.initiateUploadSampleFile(request);
    assertEquals(response.getBusinessObjectDefinitionKey(), businessObjectDefinitionKey);
    assertEquals(response.getAwsS3BucketName(), S3_BUCKET_NAME);
    assertEquals(response.getS3KeyPrefix(), expectedS3Keyprefix);
    assertEquals(response.getAwsAccessKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_ACCESS_KEY);
    assertEquals(response.getAwsSecretKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SECRET_KEY);
    assertEquals(response.getAwsSessionToken(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SESSION_TOKEN);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) UploadBusinessObjectDefinitionSampleDataFileInitiationResponse(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationResponse) UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest) Test(org.junit.Test)

Example 2 with UploadBusinessObjectDefinitionSampleDataFileInitiationRequest

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

the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFileMissingParameter.

@Test
public void testUploadBusinessObjectDefinitionSampleFileMissingParameter() {
    try {
        uploadDownloadService.initiateUploadSampleFile(null);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("An upload initiation request must be specified.", e.getMessage());
    }
    try {
        uploadDownloadService.initiateUploadSampleFile(new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(null));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition key must be specified.", e.getMessage());
    }
    try {
        BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey("NAMESPACE", null);
        UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(businessObjectDefinitionKey);
        uploadDownloadService.initiateUploadSampleFile(request);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    try {
        BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(null, "BDEF");
        UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(businessObjectDefinitionKey);
        uploadDownloadService.initiateUploadSampleFile(request);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest) Test(org.junit.Test)

Example 3 with UploadBusinessObjectDefinitionSampleDataFileInitiationRequest

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

the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFileInvalidParameter.

@Test
public void testUploadBusinessObjectDefinitionSampleFileInvalidParameter() {
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(businessObjectDefinitionKey);
    try {
        uploadDownloadService.initiateUploadSampleFile(request);
        fail();
    } catch (ObjectNotFoundException e) {
        assertEquals(businessObjectDefinitionServiceTestHelper.getExpectedBusinessObjectDefinitionNotFoundErrorMessage(NAMESPACE, BDEF_NAME), e.getMessage());
    }
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest) Test(org.junit.Test)

Example 4 with UploadBusinessObjectDefinitionSampleDataFileInitiationRequest

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

the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFileMissingTemplate.

@Test
public void testUploadBusinessObjectDefinitionSampleFileMissingTemplate() {
    // String s3_velocity_template = "$namespace/$businessObjectDefinitionName";
    String expectedS3Keyprefix = NAMESPACE.toLowerCase() + "/" + BDEF_NAME.toLowerCase() + "/";
    expectedS3Keyprefix = expectedS3Keyprefix.replace("_", "-");
    // Create a test storage.
    storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), UPLOADER_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());
    UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest();
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    request.setBusinessObjectDefinitionKey(businessObjectDefinitionKey);
    try {
        uploadDownloadService.initiateUploadSampleFile(request);
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Storage \"%s\" has no S3 key prefix velocity template configured.", StorageEntity.SAMPLE_DATA_FILE_STORAGE), e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest) Test(org.junit.Test)

Example 5 with UploadBusinessObjectDefinitionSampleDataFileInitiationRequest

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

the class UploadDownloadServiceTest method testUploadBusinessObjectDefinitionSampleFileLowerCase.

@Test
public void testUploadBusinessObjectDefinitionSampleFileLowerCase() {
    String s3_velocity_template = "$namespace/$businessObjectDefinitionName";
    // Create a test storage.
    storageDaoTestHelper.createStorageEntity(StorageEntity.SAMPLE_DATA_FILE_STORAGE, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_UPLOAD_ROLE_ARN), UPLOADER_ROLE_ARN), new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), s3_velocity_template)));
    // 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());
    UploadBusinessObjectDefinitionSampleDataFileInitiationRequest request = new UploadBusinessObjectDefinitionSampleDataFileInitiationRequest();
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME);
    BusinessObjectDefinitionKey businessObjectDefinitionKeyLowerCase = new BusinessObjectDefinitionKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase());
    request.setBusinessObjectDefinitionKey(businessObjectDefinitionKeyLowerCase);
    UploadBusinessObjectDefinitionSampleDataFileInitiationResponse response = uploadDownloadService.initiateUploadSampleFile(request);
    assertEquals(response.getBusinessObjectDefinitionKey(), businessObjectDefinitionKey);
    assertEquals(response.getAwsS3BucketName(), S3_BUCKET_NAME);
    assertEquals(response.getAwsAccessKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_ACCESS_KEY);
    assertEquals(response.getAwsSecretKey(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SECRET_KEY);
    assertEquals(response.getAwsSessionToken(), MockStsOperationsImpl.MOCK_AWS_ASSUMED_ROLE_SESSION_TOKEN);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) UploadBusinessObjectDefinitionSampleDataFileInitiationResponse(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationResponse) UploadBusinessObjectDefinitionSampleDataFileInitiationRequest(org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)8 UploadBusinessObjectDefinitionSampleDataFileInitiationRequest (org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationRequest)8 Test (org.junit.Test)8 Attribute (org.finra.herd.model.api.xml.Attribute)5 UploadBusinessObjectDefinitionSampleDataFileInitiationResponse (org.finra.herd.model.api.xml.UploadBusinessObjectDefinitionSampleDataFileInitiationResponse)5 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1