Search in sources :

Example 1 with BusinessObjectFormatParentsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatParents.

@Test
public void testUpdateBusinessObjectFormatParents() {
    // Create relative database entities including a business object definition.
    setupBusinessObjectFormatParentChild();
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null);
    BusinessObjectFormatKey parentBusinessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, null);
    BusinessObjectFormatParentsUpdateRequest updateRequest = new BusinessObjectFormatParentsUpdateRequest();
    updateRequest.setBusinessObjectFormatParents(Arrays.asList(parentBusinessObjectFormatKey));
    BusinessObjectFormat format = businessObjectFormatService.getBusinessObjectFormat(businessObjectFormatKey);
    format.setBusinessObjectFormatParents(Arrays.asList(parentBusinessObjectFormatKey));
    BusinessObjectFormat resultFormat = businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, updateRequest);
    Assert.assertEquals(format, resultFormat);
    // wipe out the parents
    businessObjectFormatService.getBusinessObjectFormat(businessObjectFormatKey);
    format.setBusinessObjectFormatParents(new ArrayList<>());
    updateRequest.setBusinessObjectFormatParents(new ArrayList<>());
    resultFormat = businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, updateRequest);
    format.setBusinessObjectFormatParents(new ArrayList<>());
    Assert.assertEquals(format, resultFormat);
}
Also used : BusinessObjectFormatParentsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatParentsUpdateRequest) 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 2 with BusinessObjectFormatParentsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatParentsValidation.

@Test
public void testUpdateBusinessObjectFormatParentsValidation() {
    List<BusinessObjectFormatKey> businessObjectFormatParents = null;
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null);
    BusinessObjectFormatParentsUpdateRequest request = null;
    try {
        businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, request);
    } catch (IllegalArgumentException ex) {
        Assert.assertEquals("A Business Object Format Parents Update Request is required.", ex.getMessage());
    }
    businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, 1);
    request = new BusinessObjectFormatParentsUpdateRequest();
    try {
        businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, request);
    } catch (IllegalArgumentException ex) {
        Assert.assertEquals("Business object format version must not be specified.", ex.getMessage());
    }
}
Also used : BusinessObjectFormatParentsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatParentsUpdateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) Test(org.junit.Test)

Example 3 with BusinessObjectFormatParentsUpdateRequest

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

the class BusinessObjectFormatRestControllerTest method testUpdateBusinessObjectFormatParents.

@Test
public void testUpdateBusinessObjectFormatParents() {
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null);
    BusinessObjectFormatKey parentBusinessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, null);
    BusinessObjectFormatParentsUpdateRequest updateRequest = new BusinessObjectFormatParentsUpdateRequest();
    updateRequest.setBusinessObjectFormatParents(Arrays.asList(parentBusinessObjectFormatKey));
    BusinessObjectFormat businessObjectFormat = new BusinessObjectFormat();
    businessObjectFormat.setBusinessObjectFormatParents(Arrays.asList(parentBusinessObjectFormatKey));
    when(businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, updateRequest)).thenReturn(businessObjectFormat);
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatRestController.updateBusinessObjectFormatParents(businessObjectFormatKey.getNamespace(), businessObjectFormatKey.getBusinessObjectDefinitionName(), businessObjectFormatKey.getBusinessObjectFormatUsage(), businessObjectFormatKey.getBusinessObjectFormatFileType(), updateRequest);
    // Verify the external calls.
    verify(businessObjectFormatService).updateBusinessObjectFormatParents(businessObjectFormatKey, updateRequest);
    verifyNoMoreInteractions(businessObjectFormatService);
    // Validate the returned object.
    assertEquals(businessObjectFormat, resultBusinessObjectFormat);
}
Also used : BusinessObjectFormatParentsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatParentsUpdateRequest) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 4 with BusinessObjectFormatParentsUpdateRequest

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

the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatParentsDuplicateParents.

@Test
public void testUpdateBusinessObjectFormatParentsDuplicateParents() {
    // Create relative database entities including a business object definition.
    setupBusinessObjectFormatParentChild();
    // Create a business object format key.
    BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION);
    // Create keys for business object format parents that are duplicates except for the case.
    List<BusinessObjectFormatKey> parentBusinessObjectFormatKeys = Arrays.asList(new BusinessObjectFormatKey(NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE_2.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), NO_FORMAT_VERSION), new BusinessObjectFormatKey(NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE_2.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), NO_FORMAT_VERSION));
    // Update parents for the business object format.
    BusinessObjectFormatParentsUpdateRequest businessObjectFormatParentsUpdateRequest = new BusinessObjectFormatParentsUpdateRequest();
    businessObjectFormatParentsUpdateRequest.setBusinessObjectFormatParents(parentBusinessObjectFormatKeys);
    BusinessObjectFormat resultBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatParents(businessObjectFormatKey, businessObjectFormatParentsUpdateRequest);
    // Validate the result. Only one business object format parent is expected to be listed.
    assertNotNull(resultBusinessObjectFormat);
    assertEquals(Arrays.asList(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION)), resultBusinessObjectFormat.getBusinessObjectFormatParents());
}
Also used : BusinessObjectFormatParentsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatParentsUpdateRequest) 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)

Aggregations

BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)4 BusinessObjectFormatParentsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatParentsUpdateRequest)4 Test (org.junit.Test)4 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)3 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)2 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)1