Search in sources :

Example 1 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitions.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitions() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    // Create an initial version of a business object format with format description and schema information.
    // Attributes are passed rather attribute definations as this method also set attribute definition by default and no need to create another method
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2();
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    // Perform an update by changing the description and schema.
    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, attributeDefinitions, businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) 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 2 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

use of org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest 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 3 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

use of org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest 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 4 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsNullAsParameters.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsNullAsParameters() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // null check for attribute definitions value
    // Perform an update by changing the attribute definition to null.
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(null);
    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("A business object format attribute definitions list is required."), ex.getMessage());
    }
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) 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 5 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

use of org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest 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

BusinessObjectFormatAttributeDefinitionsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest)9 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)9 Test (org.junit.Test)9 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)8 Attribute (org.finra.herd.model.api.xml.Attribute)7 AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)7 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)7 ArrayList (java.util.ArrayList)4 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1