use of org.finra.herd.model.api.xml.StorageUnitCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesNoStorageDirectory.
@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesNoStorageDirectory() {
// Try to create an initial version of the business object data when discovery of storage files is enabled and storage directory is not specified.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, NO_STORAGE_DIRECTORY, NO_STORAGE_FILES, DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when discovery of storage files is enabled and storage directory is not specified.");
} catch (IllegalArgumentException e) {
assertEquals("A storage directory must be specified when discovery of storage files is enabled.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageUnitCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataDiscoverStorageFilesStorageDirectoryEndsWithSlash.
@Test
public void testCreateBusinessObjectDataDiscoverStorageFilesStorageDirectoryEndsWithSlash() throws Exception {
// Create a business object format entity.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY);
// Create a business object data status entity.
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Create and upload to S3 managed storage a set of test files.
businessObjectDataServiceTestHelper.prepareTestS3Files(testS3KeyPrefix, localTempPath, LOCAL_FILES);
// Create an S3 storage entity with a bucket name attribute with a value matching to the test S3 managed storage (required for unit test clean up).
String testBucketName = storageDaoTestHelper.getS3ManagedBucketName();
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), testBucketName);
// Build a new business object data create request with enabled discovery of storage files and with storage directory ending with a slash.
String testStorageDirectoryPath = testS3KeyPrefix + "/";
BusinessObjectDataCreateRequest request = new BusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, BDATA_STATUS, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(testStorageDirectoryPath), NO_STORAGE_FILES, DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION);
// Create the business object data.
BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
// Verify the results.
assertEquals(new BusinessObjectData(resultBusinessObjectData.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, Arrays.asList(new StorageUnit(new Storage(STORAGE_NAME, StoragePlatformEntity.S3, Arrays.asList(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), testBucketName))), new StorageDirectory(testStorageDirectoryPath), businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, SORTED_LOCAL_FILES, false), StorageUnitStatusEntity.ENABLED, NO_STORAGE_UNIT_STATUS_HISTORY, NO_STORAGE_POLICY_TRANSITION_FAILED_ATTEMPTS, NO_RESTORE_EXPIRATION_ON)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_BUSINESS_OBJECT_DATA_CHILDREN, NO_BUSINESS_OBJECT_DATA_STATUS_HISTORY), resultBusinessObjectData);
}
Aggregations