use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class MessageNotificationEventServiceTest method testProcessBusinessObjectDataStatusChangeNotificationEventBusinessObjectDataAttributeNullValue.
@Test
public void testProcessBusinessObjectDataStatusChangeNotificationEventBusinessObjectDataAttributeNullValue() throws Exception {
// Create a business object data entity with a publishable attributes that has a null value.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createTestValidBusinessObjectData(SUBPARTITION_VALUES, Collections.singletonList(new AttributeDefinition(ATTRIBUTE_NAME_1_MIXED_CASE, PUBLISH_ATTRIBUTE)), Collections.singletonList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, null)));
// Get a business object data key.
BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity);
// Override configuration.
ConfigurationEntity configurationEntity = new ConfigurationEntity();
configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey());
configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_DATA_STATUS_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML, NO_MESSAGE_HEADER_DEFINITIONS)))));
configurationDao.saveAndRefresh(configurationEntity);
// Trigger the notification.
List<NotificationMessage> result = messageNotificationEventService.processBusinessObjectDataStatusChangeNotificationEvent(businessObjectDataKey, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.INVALID);
// Validate the results.
assertEquals(1, CollectionUtils.size(result));
businessObjectDataServiceTestHelper.validateBusinessObjectDataStatusChangeMessageWithXmlPayload(MESSAGE_TYPE, MESSAGE_DESTINATION, businessObjectDataKey, businessObjectDataEntity.getId(), HerdDaoSecurityHelper.SYSTEM_USER, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.INVALID, Collections.singletonList(new Attribute(ATTRIBUTE_NAME_1_MIXED_CASE, null)), NO_MESSAGE_HEADERS, result.get(0));
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceTestHelper method getTestAttributeDefinitions2.
/**
* Returns a list of attribute definitions that use hard coded test values.
*
* @return the list of test attribute definitions
*/
public List<AttributeDefinition> getTestAttributeDefinitions2() {
List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_2, AbstractServiceTest.NO_PUBLISH_ATTRIBUTE));
attributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_3, AbstractServiceTest.PUBLISH_ATTRIBUTE));
return attributeDefinitions;
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceImpl method createAttributeDefinitionEntities.
/**
* Creates a list of attribute definition entities.
*
* @param attributeDefinitions the list of attribute definitions
* @param businessObjectFormatEntity the business object format entity
*
* @return the newly created list of attribute definition entities
*/
private List<BusinessObjectDataAttributeDefinitionEntity> createAttributeDefinitionEntities(List<AttributeDefinition> attributeDefinitions, BusinessObjectFormatEntity businessObjectFormatEntity) {
List<BusinessObjectDataAttributeDefinitionEntity> attributeDefinitionEntities = new ArrayList<>();
if (!CollectionUtils.isEmpty(attributeDefinitions)) {
for (AttributeDefinition attributeDefinition : attributeDefinitions) {
// Create a new business object data attribute definition entity.
BusinessObjectDataAttributeDefinitionEntity attributeDefinitionEntity = new BusinessObjectDataAttributeDefinitionEntity();
attributeDefinitionEntities.add(attributeDefinitionEntity);
attributeDefinitionEntity.setBusinessObjectFormat(businessObjectFormatEntity);
attributeDefinitionEntity.setName(attributeDefinition.getName());
// For the "publish" option, default a Boolean null value to "false".
attributeDefinitionEntity.setPublish(BooleanUtils.isTrue(attributeDefinition.isPublish()));
}
}
return attributeDefinitionEntities;
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceImpl method validateBusinessObjectFormatCreateRequest.
/**
* Validates the business object format create request, except for the alternate key values. This method also trims request parameters.
*
* @param request the business object format create request
*
* @throws IllegalArgumentException if any validation errors were found
*/
private void validateBusinessObjectFormatCreateRequest(BusinessObjectFormatCreateRequest request) {
// Extract business object format key from the create request.
BusinessObjectFormatKey businessObjectFormatKey = getBusinessObjectFormatKey(request);
// Perform validation and trim the business object format key parameters, except for a business object format version.
businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey, false);
// Update the request object instance with the alternate key parameters.
updateBusinessObjectFormatAlternateKeyOnCreateRequest(request, businessObjectFormatKey);
// Perform validation of the partition key. This method also trims the partition key value.
request.setPartitionKey(alternateKeyHelper.validateStringParameter("partition key", request.getPartitionKey()));
// Validate attributes.
attributeHelper.validateFormatAttributes(request.getAttributes());
// Validate attribute definitions if they are specified.
if (!CollectionUtils.isEmpty(request.getAttributeDefinitions())) {
Map<String, AttributeDefinition> attributeNameValidationMap = new HashMap<>();
for (AttributeDefinition attributeDefinition : request.getAttributeDefinitions()) {
Assert.hasText(attributeDefinition.getName(), "An attribute definition name must be specified.");
attributeDefinition.setName(attributeDefinition.getName().trim());
// Ensure the attribute key isn't a duplicate by using a map with a "lowercase" name as the key for case insensitivity.
String lowercaseAttributeDefinitionName = attributeDefinition.getName().toLowerCase();
if (attributeNameValidationMap.containsKey(lowercaseAttributeDefinitionName)) {
throw new IllegalArgumentException(String.format("Duplicate attribute definition name \"%s\" found.", attributeDefinition.getName()));
}
attributeNameValidationMap.put(lowercaseAttributeDefinitionName, attributeDefinition);
}
}
// Validate optional schema information.
validateBusinessObjectFormatSchema(request.getSchema(), request.getPartitionKey());
}
use of org.finra.herd.model.api.xml.AttributeDefinition in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testUpdateBusinessObjectFormatAttributeDefinitionsTrim.
@Test
public void testUpdateBusinessObjectFormatAttributeDefinitionsTrim() {
List<Attribute> attributes = businessObjectDefinitionServiceTestHelper.getNewAttributes();
BusinessObjectFormat originalBusinessObjectFormat = businessObjectFormatServiceTestHelper.createTestBusinessObjectFormat(attributes);
// Trim should work on required parameter
List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
List<AttributeDefinition> validateAttributeDefinitions = new ArrayList<>();
validateAttributeDefinitions.add(new AttributeDefinition(AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE, AbstractServiceTest.PUBLISH_ATTRIBUTE));
attributeDefinitions.add(new AttributeDefinition(" " + AbstractServiceTest.ATTRIBUTE_NAME_1_MIXED_CASE + " ", AbstractServiceTest.PUBLISH_ATTRIBUTE));
// Perform an update by changing the attribute definition to null.
BusinessObjectFormatAttributeDefinitionsUpdateRequest request = new BusinessObjectFormatAttributeDefinitionsUpdateRequest(attributeDefinitions);
BusinessObjectFormat updatedBusinessObjectFormat = businessObjectFormatService.updateBusinessObjectFormatAttributeDefinitions(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION), request);
// Validate the returned object.
businessObjectFormatServiceTestHelper.validateBusinessObjectFormat(originalBusinessObjectFormat.getId(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, LATEST_VERSION_FLAG_SET, PARTITION_KEY, FORMAT_DESCRIPTION, attributes, validateAttributeDefinitions, businessObjectFormatServiceTestHelper.getTestSchema(), updatedBusinessObjectFormat);
}
Aggregations