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);
}
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());
}
}
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);
}
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());
}
Aggregations