Search in sources :

Example 16 with AttributeDefinition

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));
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) NotificationMessage(org.finra.herd.model.dto.NotificationMessage) Attribute(org.finra.herd.model.api.xml.Attribute) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 17 with AttributeDefinition

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;
}
Also used : ArrayList(java.util.ArrayList) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition)

Example 18 with AttributeDefinition

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;
}
Also used : BusinessObjectDataAttributeDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDataAttributeDefinitionEntity) ArrayList(java.util.ArrayList) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition)

Example 19 with AttributeDefinition

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());
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition)

Example 20 with AttributeDefinition

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);
}
Also used : Attribute(org.finra.herd.model.api.xml.Attribute) ArrayList(java.util.ArrayList) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) AttributeDefinition(org.finra.herd.model.api.xml.AttributeDefinition) BusinessObjectFormatAttributeDefinitionsUpdateRequest(org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest) DescriptiveBusinessObjectFormat(org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat) BusinessObjectFormat(org.finra.herd.model.api.xml.BusinessObjectFormat) Test(org.junit.Test)

Aggregations

AttributeDefinition (org.finra.herd.model.api.xml.AttributeDefinition)21 Test (org.junit.Test)13 Attribute (org.finra.herd.model.api.xml.Attribute)12 ArrayList (java.util.ArrayList)10 BusinessObjectFormat (org.finra.herd.model.api.xml.BusinessObjectFormat)10 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)10 BusinessObjectFormatAttributeDefinitionsUpdateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatAttributeDefinitionsUpdateRequest)8 DescriptiveBusinessObjectFormat (org.finra.herd.model.api.xml.DescriptiveBusinessObjectFormat)7 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)4 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)4 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)4 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 BusinessObjectFormatCreateRequest (org.finra.herd.model.api.xml.BusinessObjectFormatCreateRequest)3 BusinessObjectDataAttributeDefinitionEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeDefinitionEntity)3 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)3 NamespacePermission (org.finra.herd.model.annotation.NamespacePermission)2