Search in sources :

Example 36 with BusinessObjectDataCreateRequest

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());
    }
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 37 with BusinessObjectDataCreateRequest

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);
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 38 with 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());
    }
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) Test(org.junit.Test)

Example 39 with BusinessObjectDataCreateRequest

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);
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 40 with 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());
    }
}
Also used : BusinessObjectDataCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Aggregations

BusinessObjectDataCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataCreateRequest)56 Test (org.junit.Test)50 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)18 ArrayList (java.util.ArrayList)16 StorageUnitCreateRequest (org.finra.herd.model.api.xml.StorageUnitCreateRequest)14 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)11 StorageFile (org.finra.herd.model.api.xml.StorageFile)11 Attribute (org.finra.herd.model.api.xml.Attribute)10 StorageDirectory (org.finra.herd.model.api.xml.StorageDirectory)9 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)6 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)6 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)5 AlreadyExistsException (org.finra.herd.model.AlreadyExistsException)4 StorageUnit (org.finra.herd.model.api.xml.StorageUnit)3 StorageEntity (org.finra.herd.model.jpa.StorageEntity)3 HashMap (java.util.HashMap)2 FieldExtension (org.activiti.bpmn.model.FieldExtension)2 BusinessObjectDataStorageUnitCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitCreateRequest)2 Parameter (org.finra.herd.model.api.xml.Parameter)2 Storage (org.finra.herd.model.api.xml.Storage)2