Search in sources :

Example 6 with AttributeDefinition

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsMissingRequiredParameters.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsMissingRequiredParameters() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // Null as required parameter
    List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition(null, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
    // Perform an update by changing the attribute definition to null.
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException.");
    } catch (IllegalArgumentException ex) {
        assertEquals(String.format("An attribute definition name must be specified."), ex.getMessage());
    }
    // Blank string as required parameter
    attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition("", AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
    // Perform an update by changing the attribute definition to null.
    request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException.");
    } catch (IllegalArgumentException ex) {
        assertEquals(String.format("An attribute definition name must be specified."), ex.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 7 with AttributeDefinition

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatNoAttributeDefinitionPublishOptionSpecified.

@Test
public void testCreateBusinessObjectFormatNoAttributeDefinitionPublishOptionSpecified() {
    // Create relative database entities including a business object definition.
    businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting(NAMESPACE, DATA_PROVIDER_NAME, BDEF_NAME, FORMAT_FILE_TYPE_CODE, PARTITION_KEY_GROUP);
    // Perform a create without specifying a publish option for an attribute definition.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, NO_FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), Arrays.asList(new AttributeDefinition(ATTRIBUTE_NAME_1_MIXED_CASE, null)), NO_SCHEMA);
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.createBusinessObjectFormat(request);
    // Validate the returned object. The publish option is expected to default to "false".
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(null, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, NO_FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), Arrays.asList(new AttributeDefinition(ATTRIBUTE_NAME_1_MIXED_CASE, NO_PUBLISH_ATTRIBUTE)), NO_SCHEMA, resultBusinessObjectFormat);
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 8 with AttributeDefinition

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsMissingOptionalParameters.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsMissingOptionalParameters() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // Passing null as optional parameter
    List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, null));
    // Perform an update by changing the attribute definition with an empty list.
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException.");
    } catch (NullPointerException ex) {
        assertEquals(null, ex.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Example 9 with AttributeDefinition

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

the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatDuplicateAttributeDefinitions.

@Test
public void testCreateBusinessObjectFormatDuplicateAttributeDefinitions() {
    // Create a business object format create request.
    BusinessObjectFormatCreateRequest request = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
    // Add in duplicate attribute definition.
    AttributeDefinition attributeDefinition = new AttributeDefinition();
    attributeDefinition.setName(ATTRIBUTE_NAME_1_MIXED_CASE);
    request.getAttributeDefinitions().add(attributeDefinition);
    // Create the business object format which is invalid since duplicate attribute definitions are present.
    try {
        businessObjectFormatService.createBusinessObjectFormat(request);
        fail("Expecting an Illegal Argument Exception to be thrown which wasn't since duplicate attribute definitions are present.");
    } catch (IllegalArgumentException ex) {
    // We are expecting this exception so do nothing.
    }
}
Also used : BusinessObjectFormatCreateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) Test(org.junit.Test)

Example 10 with AttributeDefinition

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsUpperAndLowerCase.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsUpperAndLowerCase() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // Upper case and lower case
    List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
    List<AttributeDefinition> validateAttributeDefinitions = new ArrayList<>();
    validateAttributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.PUBLISH_ATTRIBUTE));
    attributeDefinitions.add(new AttributeDefinition(" " + AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE + " ", AbstractServiceTest.PUBLISH_ATTRIBUTE));
    // Perform an update by changing the attribute definition to null.
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(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, validateAttributeDefinitions, businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
    // upper case and lower case
    attributeDefinitions = new ArrayList<>();
    // List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2();
    attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), AbstractServiceTest.PUBLISH_ATTRIBUTE));
    attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), AbstractServiceTest.PUBLISH_ATTRIBUTE));
    // Perform an update by changing the attribute definition with an empty list.
    request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Should throw an IllegalArgumentException.");
    } catch (IllegalArgumentException ex) {
        assertEquals(String.format("Duplicate attribute definition name \"%s\" found.", ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase()), ex.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Aggregations

AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)21 Test (org.junit.Test)13 Attribute (org.finra.herd.model.api.xml.Attribute)12 ArrayList (java.util.ArrayList)10 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)10 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)10 BusinessObjectFormatAttributeDefinitionsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest)8 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)7 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)4 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)4 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)4 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)3 BusinessObjectDataAttributeDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeDefinitionEntity)3 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)3 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)2