Search in sources :

Example 6 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

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

the class BusinessObjectFormatRestControllerTest method testUpdateBusinessObjectFormatAttributeDefinitions.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitions() {
    List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions();
    BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat();
    businessObjectFormat.setAttributeDefinitions(attributeDefinitions);
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION);
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
    when(businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(businessObjectFormatKey, request)).thenReturn(businessObjectFormat);
    BusinessObjectFormat result = businessObjectFormatRestController.updateBusinessObjectFormatAttributeDefinitions(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, request);
    // Verify the external calls.
    verify(businessObjectFormatService).updateBusinessObjectFormatAttributeDefinitions(businessObjectFormatKey, request);
    verifyNoMoreInteractions(businessObjectFormatService);
    // Validate the returned object.
    assertEquals(businessObjectFormat, result);
}
Also used : BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 7 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsTrim.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsTrim() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    // Trim should work on required parameter
    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);
}
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 8 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsBusinessObjectFormatNoExists.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsBusinessObjectFormatNoExists() {
    BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2());
    try {
        businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
        fail("Business object format does not exist: No update con be performed if the format does not exists.");
    } catch (ObjectNotFoundException ex) {
        assertEquals(String.format("Business object format with namespace \"%s\", business object definition name \"%s\", format usage \"%s\", format file type \"%s\", and format version \"%s\" doesn't exist.", NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), ex.getMessage());
    }
}
Also used : ObjectNotFoundException(org.finra.herd.model.ObjectNotFoundException) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) Test(org.junit.Test)

Example 9 with BusinessObjectFormatAttributeDefinitionsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsDuplicateAttributeDefintions.

@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsDuplicateAttributeDefintions() {
    List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
    BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
    List<AttributeDefinition> attributeDefinitions = businessObjectFormatServiceTestHelper.getTestAttributeDefinitions2();
    // Check for the duplicate attribute definition.
    attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
    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("Duplicate attribute definition name \"%s\" found.", ATTRIBUTE_NAME_1_MIXED_CASE), ex.getMessage());
    }
}
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)

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