use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataParentMissingBusinessObjectDataVersion.
@Test
public void testCreateBusinessObjectDataParentMissingBusinessObjectDataVersion() {
// This will create a business object data create request with parents.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(true);
// Remove the business object data version required field.
List<BusinessObjectDataKey> businessObjectDataKeys = businessObjectDataCreateRequest.getBusinessObjectDataParents();
businessObjectDataKeys.get(0).setBusinessObjectDataVersion(null);
// Try to create a business object data which should fail since one of the required attributes is missing.
try {
businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
fail("Should throw an IllegalArgumentException when business object data version is not specified for a business object data parent.");
} catch (IllegalArgumentException e) {
assertEquals("A business object data version must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataInvalidParameters.
@Test
public void testCreateBusinessObjectDataInvalidParameters() {
// Try to create a business object data when namespace contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(addSlash(BDEF_NAMESPACE), BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when namespace contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Namespace can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when business object definition name contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, addSlash(BDEF_NAME), FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when business object definition name contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Business object definition name can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when business object format usage contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, BDEF_NAME, addSlash(FORMAT_USAGE_CODE), FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when business object format usage contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Business object format usage can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when business object format file type contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, addSlash(FORMAT_FILE_TYPE_CODE), FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when business object format file type contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Business object format file type can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when partition key contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, addSlash(PARTITION_KEY), PARTITION_VALUE, SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when partition key contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Partition key can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when partition value contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, addSlash(PARTITION_VALUE), SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when partition value contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Partition value can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when a sub-partition value contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, Arrays.asList(addSlash(PARTITION_VALUE_2)), BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), NO_ATTRIBUTES, NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when sub-partition value contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Subpartition value can not contain a forward slash character.", e.getMessage());
}
// Try to create a business object data when an attribute name contains a forward slash character.
try {
businessObjectDataService.createBusinessObjectData(new BusinessObjectDataCreateRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_KEY, PARTITION_VALUE, SUBPARTITION_VALUES, BusinessObjectDataStatusEntity.VALID, Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, new StorageDirectory(STORAGE_DIRECTORY_PATH), NO_STORAGE_FILES, NO_DISCOVER_STORAGE_FILES)), Arrays.asList(new Attribute(addSlash(ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1)), NO_BUSINESS_OBJECT_DATA_PARENTS, NO_CREATE_NEW_VERSION));
fail("Should throw an IllegalArgumentException when attribute name contains a forward slash character.");
} catch (IllegalArgumentException e) {
assertEquals("Attribute name can not contain a forward slash character.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest 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.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataParentMissingBusinessObjectFormatVersion.
@Test
public void testCreateBusinessObjectDataParentMissingBusinessObjectFormatVersion() {
// This will create a business object data create request with parents.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(true);
// Remove the business object format version required field.
List<BusinessObjectDataKey> businessObjectDataKeys = businessObjectDataCreateRequest.getBusinessObjectDataParents();
businessObjectDataKeys.get(0).setBusinessObjectFormatVersion(null);
// Try to create a business object data which should fail since one of the required attributes is missing.
try {
businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
fail("Should throw an IllegalArgumentException when business object format version is not specified for a business object data parent.");
} catch (IllegalArgumentException e) {
assertEquals("A business object format version must be specified.", e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest 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