use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleAssertTargetStorageKmsKeyIdRequired.
/**
* Asserts that error is thrown when target storage's kms kms id is not set.
*/
@Test
public void testInitiateUploadSingleAssertTargetStorageKmsKeyIdRequired() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3);
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_KEY_PREFIX_VELOCITY_TEMPLATE), "$environment/$namespace/$businessObjectDataPartitionValue"));
// Initiate a file upload.
UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3);
try {
uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("Attribute \"" + configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID) + "\" for \"" + STORAGE_NAME_3 + "\" storage must be configured.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleAssertTargetStoragePrefixTemplateRequired.
/**
* Asserts that error is thrown when target storage's prefix template is not set.
*/
@Test
public void testInitiateUploadSingleAssertTargetStoragePrefixTemplateRequired() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3);
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_KMS_KEY_ID), "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"));
// Initiate a file upload.
UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3);
try {
uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("Storage \"" + STORAGE_NAME_3 + "\" has no S3 key prefix velocity template configured.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleAssertUseTargetStorageInRequest.
/**
* Asserts that the target business object data that is created is using the target storage name that is specified in the request.
*/
@Test
public void testInitiateUploadSingleAssertUseTargetStorageInRequest() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3);
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_KEY_PREFIX_VELOCITY_TEMPLATE), "$environment/$namespace/$businessObjectDataPartitionValue"));
storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"));
// Initiate a file upload.
UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3);
UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest);
// Validate the returned object.
uploadDownloadServiceTestHelper.validateUploadSingleInitiationResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes(), FILE_NAME, FILE_SIZE_1_KB, STORAGE_NAME_3, resultUploadSingleInitiationResponse);
BusinessObjectDataEntity targetBusinessObjectDataEntity = businessObjectDataDao.getBusinessObjectDataByAltKey(new BusinessObjectDataKey(NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, resultUploadSingleInitiationResponse.getTargetBusinessObjectData().getPartitionValue(), null, 0));
assertNotNull(targetBusinessObjectDataEntity);
assertNotNull(targetBusinessObjectDataEntity.getStorageUnits());
assertEquals(1, targetBusinessObjectDataEntity.getStorageUnits().size());
StorageUnitEntity storageUnit = IterableUtils.get(targetBusinessObjectDataEntity.getStorageUnits(), 0);
assertNotNull(storageUnit);
assertNotNull(storageUnit.getStorage());
assertEquals(STORAGE_NAME_3, storageUnit.getStorage().getName());
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleAssertTargetStorageBucketNameRequired.
/**
* Asserts that error is thrown when target storage's bucket name is not set.
*/
@Test
public void testInitiateUploadSingleAssertTargetStorageBucketNameRequired() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3);
storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), "$environment/$namespace/$businessObjectDataPartitionValue"));
storageEntity.getAttributes().add(storageDaoTestHelper.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID), "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"));
// Initiate a file upload.
UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3);
try {
uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest);
fail();
} catch (Exception e) {
assertEquals(IllegalArgumentException.class, e.getClass());
assertEquals("Attribute \"" + configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME) + "\" for \"" + STORAGE_NAME_3 + "\" storage must be configured.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.UploadSingleInitiationRequest in project herd by FINRAOS.
the class UploadDownloadServiceTest method testInitiateUploadSingleMissingOptionalParameters.
@Test
public void testInitiateUploadSingleMissingOptionalParameters() {
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
// Initiate a file upload without specifying any of the optional parameters.
UploadSingleInitiationRequest request = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
request.setBusinessObjectDataAttributes(null);
request.getFile().setFileSizeBytes(null);
UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(request);
// Validate the returned object.
uploadDownloadServiceTestHelper.validateUploadSingleInitiationResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, NO_ATTRIBUTES, FILE_NAME, null, null, resultUploadSingleInitiationResponse);
}
Aggregations