use of org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity in project herd by FINRAOS.
the class DefaultNotificationMessageBuilder method getBusinessObjectDataStatusChangeMessageVelocityContextMap.
/**
* Returns Velocity context map of additional keys and values to place in the velocity context.
*
* @param businessObjectDataKey the business object data key
* @param newBusinessObjectDataStatus the new business object data status
* @param oldBusinessObjectDataStatus the old business object data status
*
* @return the Velocity context map
*/
private Map<String, Object> getBusinessObjectDataStatusChangeMessageVelocityContextMap(BusinessObjectDataKey businessObjectDataKey, String newBusinessObjectDataStatus, String oldBusinessObjectDataStatus) {
// Create a context map of values that can be used when building the message.
Map<String, Object> velocityContextMap = new HashMap<>();
velocityContextMap.put("businessObjectDataKey", businessObjectDataKey);
velocityContextMap.put("newBusinessObjectDataStatus", newBusinessObjectDataStatus);
velocityContextMap.put("oldBusinessObjectDataStatus", oldBusinessObjectDataStatus);
// Retrieve business object data entity and business object data id to the context.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
velocityContextMap.put("businessObjectDataId", businessObjectDataEntity.getId());
// Load all attribute definitions for this business object data in a map for easy access.
Map<String, BusinessObjectDataAttributeDefinitionEntity> attributeDefinitionEntityMap = businessObjectFormatHelper.getAttributeDefinitionEntities(businessObjectDataEntity.getBusinessObjectFormat());
// Build an ordered map of business object data attributes that are flagged to be published in notification messages.
Map<String, String> businessObjectDataAttributes = new LinkedHashMap<>();
if (!attributeDefinitionEntityMap.isEmpty()) {
for (BusinessObjectDataAttributeEntity attributeEntity : businessObjectDataEntity.getAttributes()) {
if (attributeDefinitionEntityMap.containsKey(attributeEntity.getName().toUpperCase())) {
BusinessObjectDataAttributeDefinitionEntity attributeDefinitionEntity = attributeDefinitionEntityMap.get(attributeEntity.getName().toUpperCase());
if (BooleanUtils.isTrue(attributeDefinitionEntity.getPublish())) {
businessObjectDataAttributes.put(attributeEntity.getName(), attributeEntity.getValue());
}
}
}
}
// Add the map of business object data attributes to the context.
velocityContextMap.put("businessObjectDataAttributes", businessObjectDataAttributes);
// Add the namespace to the header.
velocityContextMap.put("namespace", businessObjectDataKey.getNamespace());
return velocityContextMap;
}
use of org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity in project herd by FINRAOS.
the class GetBusinessObjectDataAttributeTest method testGetBusinessObjectDataAttributeMissingOptionalParameters.
@Test
public void testGetBusinessObjectDataAttributeMissingOptionalParameters() throws Exception {
// Create a business object data key without sub-partition values.
BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, DATA_VERSION);
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataAttributeName", "${businessObjectDataAttributeName}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
parameters.add(buildParameter("businessObjectDataAttributeName", ATTRIBUTE_NAME_1_MIXED_CASE));
// Build the expected response object.
BusinessObjectDataAttribute expectedBusinessObjectDataAttribute = new BusinessObjectDataAttribute(businessObjectDataAttributeEntity.getId(), businessObjectDataAttributeHelper.getBusinessObjectDataAttributeKey(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1);
// Run the activiti task and validate the returned response object.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetBusinessObjectDataAttribute.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataAttribute));
testActivitiServiceTaskSuccess(GetBusinessObjectDataAttribute.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity in project herd by FINRAOS.
the class GetBusinessObjectDataAttributeTest method testGetBusinessObjectDataAttribute.
@Test
public void testGetBusinessObjectDataAttribute() throws Exception {
// 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 business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = businessObjectDataAttributeDaoTestHelper.createBusinessObjectDataAttributeEntity(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE, ATTRIBUTE_VALUE_1);
List<FieldExtension> fieldExtensionList = new ArrayList<>();
fieldExtensionList.add(buildFieldExtension("namespace", "${namespace}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDefinitionName", "${businessObjectDefinitionName}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatUsage", "${businessObjectFormatUsage}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatFileType", "${businessObjectFormatFileType}"));
fieldExtensionList.add(buildFieldExtension("businessObjectFormatVersion", "${businessObjectFormatVersion}"));
fieldExtensionList.add(buildFieldExtension("partitionValue", "${partitionValue}"));
fieldExtensionList.add(buildFieldExtension("subPartitionValues", "${subPartitionValues}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataVersion", "${businessObjectDataVersion}"));
fieldExtensionList.add(buildFieldExtension("businessObjectDataAttributeName", "${businessObjectDataAttributeName}"));
List<Parameter> parameters = new ArrayList<>();
parameters.add(buildParameter("namespace", BDEF_NAMESPACE));
parameters.add(buildParameter("businessObjectDefinitionName", BDEF_NAME));
parameters.add(buildParameter("businessObjectFormatUsage", FORMAT_USAGE_CODE));
parameters.add(buildParameter("businessObjectFormatFileType", FORMAT_FILE_TYPE_CODE));
parameters.add(buildParameter("businessObjectFormatVersion", FORMAT_VERSION.toString()));
parameters.add(buildParameter("partitionValue", PARTITION_VALUE));
parameters.add(buildParameter("subPartitionValues", herdStringHelper.buildStringWithDefaultDelimiter(SUBPARTITION_VALUES)));
parameters.add(buildParameter("businessObjectDataVersion", DATA_VERSION.toString()));
parameters.add(buildParameter("businessObjectDataAttributeName", ATTRIBUTE_NAME_1_MIXED_CASE));
// Build the expected response object.
BusinessObjectDataAttribute expectedBusinessObjectDataAttribute = new BusinessObjectDataAttribute(businessObjectDataAttributeEntity.getId(), businessObjectDataAttributeHelper.getBusinessObjectDataAttributeKey(businessObjectDataKey, ATTRIBUTE_NAME_1_MIXED_CASE), ATTRIBUTE_VALUE_1);
// Run the activiti task and validate the returned response object.
Map<String, Object> variableValuesToValidate = new HashMap<>();
variableValuesToValidate.put(GetBusinessObjectDataAttribute.VARIABLE_JSON_RESPONSE, jsonHelper.objectToJson(expectedBusinessObjectDataAttribute));
testActivitiServiceTaskSuccess(GetBusinessObjectDataAttribute.class.getCanonicalName(), fieldExtensionList, parameters, variableValuesToValidate);
}
use of org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity in project herd by FINRAOS.
the class AttributeDaoHelperTest method testUpdateBusinessObjectDataAttributesAttributeDeleted.
@Test
public void testUpdateBusinessObjectDataAttributesAttributeDeleted() {
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME);
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, NO_ATTRIBUTES);
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(0, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
}
use of org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity in project herd by FINRAOS.
the class AttributeDaoHelperTest method testUpdateBusinessObjectDataAttributesAttributeValueUpdated.
@Test
public void testUpdateBusinessObjectDataAttributesAttributeValueUpdated() {
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME);
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE_2)));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity result = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(ATTRIBUTE_NAME, result.getName());
assertEquals(ATTRIBUTE_VALUE_2, result.getValue());
}
Aggregations