use of org.finra.herd.model.api.xml.BusinessObjectDataAttributesUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceImplTest method testUpdateBusinessObjectDataAttributesMissingRequiredParameters.
@Test
public void testUpdateBusinessObjectDataAttributesMissingRequiredParameters() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Try to update business object data attributes when the update request is not specified.
try {
businessObjectDataServiceImpl.updateBusinessObjectDataAttributes(businessObjectDataKey, null);
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("A business object data attributes update request must be specified."), e.getMessage());
}
// Try to update business object data attributes when the list of attributes is not specified.
try {
businessObjectDataServiceImpl.updateBusinessObjectDataAttributes(businessObjectDataKey, new BusinessObjectDataAttributesUpdateRequest());
fail();
} catch (IllegalArgumentException e) {
assertEquals(String.format("A list of business object data attributes must be specified."), e.getMessage());
}
// Verify the external calls.
verify(businessObjectDataHelper, times(2)).validateBusinessObjectDataKey(businessObjectDataKey, true, true);
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.api.xml.BusinessObjectDataAttributesUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataRestControllerTest method testUpdateBusinessObjectDataAttributes.
@Test
public void testUpdateBusinessObjectDataAttributes() {
// Create a list of business object data keys with all possible number of sub-partition values.
List<BusinessObjectDataKey> businessObjectDataKeys = new ArrayList<>();
for (int subPartitionValuesCount = 0; subPartitionValuesCount <= SUBPARTITION_VALUES.size(); subPartitionValuesCount++) {
businessObjectDataKeys.add(new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.subList(0, subPartitionValuesCount), DATA_VERSION));
}
// Create a business object data attributes update request.
BusinessObjectDataAttributesUpdateRequest businessObjectDataAttributesUpdateRequest = new BusinessObjectDataAttributesUpdateRequest(Collections.singletonList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE)));
// Create a list of business object data instances one per business object data key.
List<BusinessObjectData> businessObjectDataList = new ArrayList<>();
for (BusinessObjectDataKey businessObjectDataKey : businessObjectDataKeys) {
BusinessObjectData businessObjectData = new BusinessObjectData();
businessObjectData.setNamespace(businessObjectDataKey.getNamespace());
businessObjectData.setBusinessObjectDefinitionName(businessObjectDataKey.getBusinessObjectDefinitionName());
businessObjectData.setBusinessObjectFormatUsage(businessObjectDataKey.getBusinessObjectFormatUsage());
businessObjectData.setBusinessObjectFormatFileType(businessObjectDataKey.getBusinessObjectFormatFileType());
businessObjectData.setBusinessObjectFormatVersion(businessObjectDataKey.getBusinessObjectFormatVersion());
businessObjectData.setPartitionValue(businessObjectDataKey.getPartitionValue());
businessObjectData.setSubPartitionValues(businessObjectDataKey.getSubPartitionValues());
businessObjectData.setVersion(businessObjectDataKey.getBusinessObjectDataVersion());
businessObjectDataList.add(businessObjectData);
}
// Mock the external calls.
for (int subPartitionValuesCount = 0; subPartitionValuesCount <= SUBPARTITION_VALUES.size(); subPartitionValuesCount++) {
when(businessObjectDataService.updateBusinessObjectDataAttributes(businessObjectDataKeys.get(subPartitionValuesCount), businessObjectDataAttributesUpdateRequest)).thenReturn(businessObjectDataList.get(subPartitionValuesCount));
}
// Call the methods under test and validate the results.
assertEquals(businessObjectDataList.get(0), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, DATA_VERSION, businessObjectDataAttributesUpdateRequest));
assertEquals(businessObjectDataList.get(1), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
assertEquals(businessObjectDataList.get(2), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
assertEquals(businessObjectDataList.get(3), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
assertEquals(businessObjectDataList.get(4), businessObjectDataRestController.updateBusinessObjectDataAttributes(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES.get(0), SUBPARTITION_VALUES.get(1), SUBPARTITION_VALUES.get(2), SUBPARTITION_VALUES.get(3), DATA_VERSION, businessObjectDataAttributesUpdateRequest));
// Verify the external calls.
for (BusinessObjectDataKey businessObjectDataKey : businessObjectDataKeys) {
verify(businessObjectDataService).updateBusinessObjectDataAttributes(businessObjectDataKey, businessObjectDataAttributesUpdateRequest);
}
verifyNoMoreInteractionsHelper();
}
use of org.finra.herd.model.api.xml.BusinessObjectDataAttributesUpdateRequest in project herd by FINRAOS.
the class BusinessObjectDataServiceImplTest method testUpdateBusinessObjectDataAttributes.
@Test
public void testUpdateBusinessObjectDataAttributes() {
// Create a business object data key.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION);
// Create a list of attributes.
List<Attribute> attributes = Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE));
// Create a business object data attributes update request.
BusinessObjectDataAttributesUpdateRequest businessObjectDataAttributesUpdateRequest = new BusinessObjectDataAttributesUpdateRequest(attributes);
// Create a list of attribute definitions.
List<BusinessObjectDataAttributeDefinitionEntity> attributeDefinitionEntities = Arrays.asList(new BusinessObjectDataAttributeDefinitionEntity());
// Create a business object format definition.
BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
businessObjectFormatEntity.setAttributeDefinitions(attributeDefinitionEntities);
// Create a business object data entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
businessObjectDataEntity.setBusinessObjectFormat(businessObjectFormatEntity);
// Create a business object data.
BusinessObjectData businessObjectData = new BusinessObjectData();
businessObjectData.setId(ID);
// Mock the external calls.
when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity);
when(businessObjectDataDao.saveAndRefresh(businessObjectDataEntity)).thenReturn(businessObjectDataEntity);
when(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity)).thenReturn(businessObjectData);
// Call the method under test.
BusinessObjectData result = businessObjectDataServiceImpl.updateBusinessObjectDataAttributes(businessObjectDataKey, businessObjectDataAttributesUpdateRequest);
// Verify the external calls.
verify(businessObjectDataHelper).validateBusinessObjectDataKey(businessObjectDataKey, true, true);
verify(attributeHelper).validateAttributes(attributes);
verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey);
verify(attributeDaoHelper).validateAttributesAgainstBusinessObjectDataAttributeDefinitions(attributes, attributeDefinitionEntities);
verify(attributeDaoHelper).updateBusinessObjectDataAttributes(businessObjectDataEntity, attributes);
verify(businessObjectDataDao).saveAndRefresh(businessObjectDataEntity);
verify(businessObjectDataHelper).createBusinessObjectDataFromEntity(businessObjectDataEntity);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(businessObjectData, result);
}
Aggregations