Search in sources :

Example 1 with BusinessObjectDefinitionUpdateRequest

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionDuplicateAttributes.

@Test
public void testUpdateBusinessObjectDefinitionDuplicateAttributes() {
    // Try to update a business object definition instance when duplicate attributes are specified.
    try {
        businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE, BDEF_NAME), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_3), new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_3))));
        fail("Should throw an IllegalArgumentException when duplicate attributes are specified.");
    } catch (IllegalArgumentException e) {
        assertEquals(String.format("Duplicate attribute name found: %s", ATTRIBUTE_NAME_3_MIXED_CASE.toUpperCase()), e.getMessage());
    }
}
Also used : BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest) Test(org.junit.Test)

Example 2 with BusinessObjectDefinitionUpdateRequest

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionLowerCaseParameters.

@Test
public void testUpdateBusinessObjectDefinitionLowerCaseParameters() {
    // Create and persist a business object definition entity using upper case values.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), DATA_PROVIDER_NAME.toUpperCase(), BDEF_DESCRIPTION.toUpperCase(), BDEF_DISPLAY_NAME.toUpperCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1.toUpperCase())));
    // Perform an update using lower case input parameters.
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase()), new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2.toLowerCase(), BDEF_DISPLAY_NAME_2.toLowerCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toLowerCase(), ATTRIBUTE_VALUE_1.toLowerCase()))));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), DATA_PROVIDER_NAME.toUpperCase(), BDEF_DESCRIPTION_2.toLowerCase(), NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2.toLowerCase(), Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE.toUpperCase(), ATTRIBUTE_VALUE_1.toLowerCase())), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest) Test(org.junit.Test)

Example 3 with BusinessObjectDefinitionUpdateRequest

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

the class BusinessObjectDefinitionServiceTest method testUpdateBusinessObjectDefinitionTrimParameters.

@Test
public void testUpdateBusinessObjectDefinitionTrimParameters() {
    // Create and persist a business object definition entity.
    BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, BDEF_DISPLAY_NAME, businessObjectDefinitionServiceTestHelper.getNewAttributes());
    // Perform an update using input parameters with leading and trailing empty spaces.
    BusinessObjectDefinition updatedBusinessObjectDefinition = businessObjectDefinitionService.updateBusinessObjectDefinition(new BusinessObjectDefinitionKey(addWhitespace(NAMESPACE), addWhitespace(BDEF_NAME)), new BusinessObjectDefinitionUpdateRequest(addWhitespace(BDEF_DESCRIPTION_2), addWhitespace(BDEF_DISPLAY_NAME_2), Arrays.asList(new Attribute(addWhitespace(ATTRIBUTE_NAME_1_MIXED_CASE), addWhitespace(ATTRIBUTE_VALUE_1)))));
    // Validate the returned object.
    assertEquals(new BusinessObjectDefinition(businessObjectDefinitionEntity.getId(), NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, addWhitespace(BDEF_DESCRIPTION_2), NO_BDEF_SHORT_DESCRIPTION, BDEF_DISPLAY_NAME_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, addWhitespace(ATTRIBUTE_VALUE_1))), NO_DESCRIPTIVE_BUSINESS_OBJECT_FORMAT, NO_SAMPLE_DATA_FILES, businessObjectDefinitionEntity.getCreatedBy(), businessObjectDefinitionEntity.getUpdatedBy(), HerdDateUtils.getXMLGregorianCalendarValue(businessObjectDefinitionEntity.getUpdatedOn()), NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS), updatedBusinessObjectDefinition);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) BusinessObjectDefinitionUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest) Test(org.junit.Test)

Example 4 with BusinessObjectDefinitionUpdateRequest

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

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

the class BusinessObjectDefinitionRestControllerTest method testUpdateBusinessObjectDefinition.

@Test
public void testUpdateBusinessObjectDefinition() {
    // Create a business object definition key.
    BusinessObjectDefinitionKey businessObjectDefinitionKey = new BusinessObjectDefinitionKey(BDEF_NAMESPACE, BDEF_NAME);
    // Create a business object definition update request.
    BusinessObjectDefinitionUpdateRequest businessObjectDefinitionUpdateRequest = new BusinessObjectDefinitionUpdateRequest(BDEF_DESCRIPTION_2, BDEF_DISPLAY_NAME_2, Arrays.asList(new Attribute(ATTRIBUTE_NAME_2_MIXED_CASE, ATTRIBUTE_VALUE_2)));
    // Create a business object definition.
    BusinessObjectDefinition businessObjectDefinition = new BusinessObjectDefinition(ID, BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION, SHORT_DESCRIPTION, BDEF_DISPLAY_NAME, Arrays.asList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1)), new DescriptiveBusinessObjectFormat(FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION), Arrays.asList(new SampleDataFile(DIRECTORY_PATH, FILE_NAME)), CREATED_BY, UPDATED_BY, UPDATED_ON, NO_BUSINESS_OBJECT_DEFINITION_CHANGE_EVENTS);
    // Mock the external calls.
    when(businessObjectDefinitionService.updateBusinessObjectDefinition(businessObjectDefinitionKey, businessObjectDefinitionUpdateRequest)).thenReturn(businessObjectDefinition);
    // Call the method under test.
    BusinessObjectDefinition result = businessObjectDefinitionRestController.updateBusinessObjectDefinition(BDEF_NAMESPACE, BDEF_NAME, businessObjectDefinitionUpdateRequest);
    // Verify the external calls.
    verify(businessObjectDefinitionService).updateBusinessObjectDefinition(businessObjectDefinitionKey, businessObjectDefinitionUpdateRequest);
    verifyNoMoreInteractions(businessObjectDefinitionService);
    // Validate the results.
    assertEquals(businessObjectDefinition, result);
}
Also used : BusinessObjectDefinition(org.finra.herd.model.api.xml.BusinessObjectDefinition) SampleDataFile(org.finra.herd.model.api.xml.SampleDataFile) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectDefinitionKey(org.finra.herd.model.api.xml.BusinessObjectDefinitionKey) Attribute(org.finra.herd.model.api.xml.Attribute) BusinessObjectDefinitionUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest) Test(org.junit.Test)

Aggregations

BusinessObjectDefinitionKey (org.finra.herd.model.api.xml.BusinessObjectDefinitionKey)11 BusinessObjectDefinitionUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionUpdateRequest)11 Test (org.junit.Test)11 Attribute (org.finra.herd.model.api.xml.Attribute)7 BusinessObjectDefinition (org.finra.herd.model.api.xml.BusinessObjectDefinition)6 BusinessObjectDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDefinitionEntity)5 ArrayList (java.util.ArrayList)2 ObjectNotFoundException (org.finra.herd.model.ObjectNotFoundException)1 BusinessObjectDefinitionChangeEvent (org.finra.herd.model.api.xml.BusinessObjectDefinitionChangeEvent)1 BusinessObjectDefinitionCreateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionCreateRequest)1 BusinessObjectDefinitionDescriptiveInformationUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectDefinitionDescriptiveInformationUpdateRequest)1 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)1 SampleDataFile (org.finra.herd.model.api.xml.SampleDataFile)1 SearchIndexUpdateDto (org.finra.herd.model.dto.SearchIndexUpdateDto)1