Search in sources :

Example 36 with Attribute

use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.

the class BusinessObjectDefinitionServiceTest method testCreateBusinessObjectDefinitionMissingRequiredParameters.

@Test
public void testCreateBusinessObjectDefinitionMissingRequiredParameters() {
    // Try to create a business object definition instance when namespace is not specified.
    try {
        businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(BLANK_TEXT, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES));
        fail("Should throw an IllegalArgumentException when namespace is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A namespace must be specified.", e.getMessage());
    }
    // Try to create a business object definition instance when object definition name is not specified.
    try {
        businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BLANK_TEXT, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES));
        fail("Should throw an IllegalArgumentException when business object definition name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A business object definition name must be specified.", e.getMessage());
    }
    // Try to create a business object definition instance when data provider name is not specified.
    try {
        businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, BLANK_TEXT, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, NO_ATTRIBUTES));
        fail("Should throw an IllegalArgumentException when data provider name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("A data provider name must be specified.", e.getMessage());
    }
    // Try to create a business object definition instance when attribute name is not specified.
    try {
        businessObjectDefinitionService.createBusinessObjectDefinition(new BusinessObjectDefinitionCreateRequest(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays.asList(new Attribute(BLANK_TEXT, ATTRIBUTE_VALUE_1))));
        fail("Should throw an IllegalArgumentException when attribute name is not specified.");
    } catch (IllegalArgumentException e) {
        assertEquals("An attribute name must be specified.", e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionCreateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest) Test(org.junit.Test)

Example 37 with Attribute

use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionDuplicateOriginalAttributes.

@Test
public void testUpdateBusinessObjectDefinitionDuplicateOriginalAttributes() throws Exception {
    // Create and persist a business object definition entity with duplicate attributes.
    businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1), new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1_UPDATED)));
    // Try to update a business object definition that has duplicate attributes.
    try {
        businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
        fail("Should throw an IllegalStateException when business object definition contains duplicate attributes.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Found duplicate attribute with name \"%s\" for business object definition {namespace: \"%s\", businessObjectDefinitionName: \"%s\"}.", ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), NAMESPACE, BDEF_NAME), e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest) Test(org.junit.Test)

Example 38 with Attribute

use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatWithGlobalAttributesAndAllowedAttributeValuesNegative2.

@Test
public void testCreateBusinessObjectFormatWithGlobalAttributesAndAllowedAttributeValuesNegative2() {
    GlobalAttributeDefinitionEntity globalAttributeDefinitionEntity = createGlobalAttributeDefinitionEntityWithAllowedAttributeValues();
    String invalidAttributeValue = ALLOWED_ATTRIBUTE_VALUE.toLowerCase();
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, invalidAttributeValue));
    attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    attributes.add(new Attribute(GLOBAL_ATTRIBUTE_DEFINITON_NAME, invalidAttributeValue));
    // attribute value should be case sensitive
    try {
        // Create an initial version of a business object format.
        BusinessObjectFormat businessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
        fail("Should throw exception before");
    } catch (IllegalArgumentException ex) {
        assertEquals(String.format("The business object format attribute \"%s\" value \"%s\" is not from allowed attribute values.", GLOBAL_ATTRIBUTE_DEFINITON_NAME, ALLOWED_ATTRIBUTE_VALUE.toLowerCase()), ex.getMessage());
    }
}
Also used : GlobalAttributeDefinitionEntity(org.finra.herd.model.jpa.GlobalAttributeDefinitionEntity) Attribute(org.finra.herd.model.api.xml.Attribute) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 39 with Attribute

use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributes.

@Test
public void testUpdateBusinessObjectFormatAttributes() {
    // Create an initial version of a business object format with format description and schema information.
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(businessObjectDefinitionServiceTestHelper.getNewAttributes());
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes2();
    BusinessObjectFormatAttributesUpdateRequest request = new BusinessObjectFormatAttributesUpdateRequest(attributes);
    // Perform an update by changing the description and schema.
    BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatAttributes(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
    // Validate the returned object.
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(originalBusinessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, attributes, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatAttributesUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributesUpdateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 40 with Attribute

use of org.finra.herd.model.api.xml.Attribute in project herd by FINRAOS.

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAlreadyExistingDuplicateAttributes.

@Test
public void testUpdateBusinessObjectFormatAlreadyExistingDuplicateAttributes() {
    // Create and persist a business object format with duplicate attributes.
    businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, FORMAT_DESCRIPTION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, NO_PARTITION_KEY_GROUP, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1), new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_2)));
    // Try to update a business object format instance that already has duplicate attributes.
    try {
        businessObjectFormatService.updateBusinessObjectFormat(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), businessObjectFormatServiceTestHelper.createBusinessObjectFormatUpdateRequest(FORMAT_DESCRIPTION_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3)), businessObjectFormatServiceTestHelper.getTestSchema2()));
        fail("Should throw an IllegalStateException when business object format has duplicate attributes.");
    } catch (IllegalStateException e) {
        assertEquals(String.format("Found duplicate attribute with name \"%s\" for business object format {%s}.", ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), businessObjectFormatServiceTestHelper.getExpectedBusinessObjectFormatKeyAsString(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION)), e.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) Test(org.junit.Test)

Aggregations

Attribute (org.finra.herd.model.api.xml.Attribute)165 Test (org.junit.Test)121 ArrayList (java.util.ArrayList)68 BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)34 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)32 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)30 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)28 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)28 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)26 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)23 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)22 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)20 StorageEntity (org.finra.herd.model.jpa.StorageEntity)18 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)16 HashMap (java.util.HashMap)15 BusinessObjectData (org.finra.herd.model.api.xml.BusinessObjectData)15 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)15 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)14 SchemaColumn (org.finra.herd.model.api.xml.SchemaColumn)13 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)12