use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataS3ManagedBucketDirectoryPathAlreadyRegistered.
@Test
public void testCreateBusinessObjectDataS3ManagedBucketDirectoryPathAlreadyRegistered() {
// Create relative database entities including a storage unit for the business object data with PARTITION_VALUE_2 partition value,
// but with a directory path that would actually match with a test business object data with PARTITION_VALUE partition value.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE_2, INITIAL_DATA_VERSION, true, BDATA_STATUS);
storageUnitDaoTestHelper.createStorageUnitEntity(storageDao.getStorageByName(StorageEntity.MANAGED_STORAGE), businessObjectDataEntity, StorageUnitStatusEntity.ENABLED, testS3KeyPrefix);
// Build a new business object data create request containing the already registered storage directory path.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, StorageEntity.MANAGED_STORAGE, testS3KeyPrefix, businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, Arrays.asList(LOCAL_FILE)));
try {
// Try to create a business object data instance.
businessObjectDataService.createBusinessObjectData(request);
fail("Should throw an AlreadyExistsException when directory path in S3 managed " + "storage matches the location of an already registered business object data.");
} catch (AlreadyExistsException e) {
assertEquals(String.format("Storage directory \"%s\" in \"%s\" storage is already registered by the business object data {%s}.", testS3KeyPrefix, StorageEntity.MANAGED_STORAGE, businessObjectDataServiceTestHelper.getExpectedBusinessObjectDataKeyAsString(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE_2, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION)), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataMissingOptionalParameters.
@Test
public void testCreateBusinessObjectDataMissingOptionalParameters() {
// Create relative database entities.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
// Create an initial version of business object data without specifying any of the optional parameters except for namespace.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, null);
assertNull(request.getSubPartitionValues());
request.setStatus(BLANK_TEXT);
assertNull(request.getAttributes());
assertNull(request.getStorageUnits().get(0).getStorageFiles());
request.setCreateNewVersion(null);
assertNull(request.getBusinessObjectDataParents());
BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
// Verify the results.
businessObjectDataServiceTestHelper.validateBusinessObjectData(request, INITIAL_DATA_VERSION, true, resultBusinessObjectData);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataValidateFileExistenceNoValidatePrefix.
@Test
public void testCreateBusinessObjectDataValidateFileExistenceNoValidatePrefix() throws Exception {
// Create an S3 storage entity.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, StoragePlatformEntity.S3, attributes);
// Create relative database entities.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Build a list of storage files.
List<StorageFile> storageFiles = businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, LOCAL_FILES);
// Create and upload to S3 managed storage a set of test files.
businessObjectDataServiceTestHelper.prepareTestS3Files(S3_BUCKET_NAME, testS3KeyPrefix, localTempPath, LOCAL_FILES, new ArrayList<String>());
// Build a new business object data create request.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, storageFiles);
// Try to create a business object data instance. It should go through without any errors.
businessObjectDataService.createBusinessObjectData(request);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataNoStorageFiles.
@Test
public void testCreateBusinessObjectDataNoStorageFiles() {
// Create the initial version of the business object data without specifying storage files.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest();
request.getStorageUnits().get(0).setStorageFiles(null);
BusinessObjectData resultBusinessObjectData = businessObjectDataService.createBusinessObjectData(request);
// Verify the results.
businessObjectDataServiceTestHelper.validateBusinessObjectData(request, INITIAL_DATA_VERSION, true, resultBusinessObjectData);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataValidateFlagIgnoredForNonS3Storage.
@Test
public void testCreateBusinessObjectDataValidateFlagIgnoredForNonS3Storage() throws Exception {
// Create an S3 storage entity.
List<Attribute> attributes = new ArrayList<>();
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), S3_BUCKET_NAME));
attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_VALIDATE_FILE_EXISTENCE), Boolean.TRUE.toString()));
storageDaoTestHelper.createStorageEntity(STORAGE_NAME, "NON_S3_STORAGE", attributes);
// Create relative database entities.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, true, PARTITION_KEY);
businessObjectDataStatusDaoTestHelper.createBusinessObjectDataStatusEntity(BDATA_STATUS);
// Build a list of storage files.
List<StorageFile> storageFiles = businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, LOCAL_FILES);
// Build a new business object data create request.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, storageFiles);
// Try to create a business object data instance. This should succeed since the bucket is not of type "S3", even though there are no files in S3.
businessObjectDataService.createBusinessObjectData(request);
}
Aggregations