use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataInvalidStorageFile.
@Test
public void testCreateBusinessObjectDataInvalidStorageFile() {
// 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);
storageDaoTestHelper.createStorageEntity(STORAGE_NAME);
// Build a business object data create request with a storage file path not matching the storage directory path.
String wrongS3KeyPrefix = "WRONG_S3_KEY_PREFIX";
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, businessObjectDataServiceTestHelper.getTestStorageFiles(wrongS3KeyPrefix, Arrays.asList(LOCAL_FILE)));
try {
// Try to create a business object data instance.
businessObjectDataService.createBusinessObjectData(request);
fail("Should throw an IllegalArgumentException when a storage storage file path does not match the storage directory path.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Storage file path \"%s/%s\" does not match the storage directory path \"%s\".", wrongS3KeyPrefix, LOCAL_FILE, testS3KeyPrefix), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataMissingRequiredAttribute.
@Test(expected = IllegalArgumentException.class)
public void testCreateBusinessObjectDataMissingRequiredAttribute() {
// This will create a business object data create request with attributes. It will be associated with a format that has attribute definitions
// that require the attribute to be specified.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(true);
// Null out the attributes in the create request, even though the format requires them.
businessObjectDataCreateRequest.setAttributes(null);
// Create the business object data which should fail since required attributes are missing.
businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataInvalidPartitionKey.
@Test
public void testCreateBusinessObjectDataInvalidPartitionKey() {
// 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);
// Try to create a business object data instance when an invalid partition key value is specified.
BusinessObjectDataCreateRequest request = businessObjectDataServiceTestHelper.createBusinessObjectDataCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, "INVALID_PARTITION_KEY", PARTITION_VALUE, BDATA_STATUS, STORAGE_NAME, testS3KeyPrefix, businessObjectDataServiceTestHelper.getTestStorageFiles(testS3KeyPrefix, Arrays.asList(LOCAL_FILE)));
try {
businessObjectDataService.createBusinessObjectData(request);
fail("Should throw an IllegalArgumentException when an invalid partition key value is specified.");
} catch (IllegalArgumentException e) {
assertEquals(String.format("Partition key \"%s\" doesn't match configured business object format partition key \"%s\".", request.getPartitionKey(), PARTITION_KEY), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataParentNoExists.
@Test(expected = ObjectNotFoundException.class)
public void testCreateBusinessObjectDataParentNoExists() {
// This will create a business object data create request with parents.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(true);
// Set the partition value to a business object data that doesn't exist.
List<BusinessObjectDataKey> businessObjectDataKeys = businessObjectDataCreateRequest.getBusinessObjectDataParents();
businessObjectDataKeys.get(0).setPartitionValue("Invalid_Partition_Value");
// Create the business object data which should fail since required attributes are missing.
businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest);
}
use of org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceCreateBusinessObjectDataTest method testCreateBusinessObjectDataParentMissingPartitionValue.
@Test
public void testCreateBusinessObjectDataParentMissingPartitionValue() {
// This will create a business object data create request with parents.
BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(true);
// Remove the partition value required field.
List<BusinessObjectDataKey> businessObjectDataKeys = businessObjectDataCreateRequest.getBusinessObjectDataParents();
businessObjectDataKeys.get(0).setPartitionValue(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 partition value is not specified for a business object data parent.");
} catch (IllegalArgumentException e) {
assertEquals("A partition value must be specified.", e.getMessage());
}
}
Aggregations