Search in sources :

Example 6 with MessageHeaderDefinition

use of org.finra.herd.model.api.xml.MessageHeaderDefinition in project herd by FINRAOS.

the class MessageNotificationEventServiceTest method testProcessBusinessObjectDataStatusChangeNotificationEventNoMessageDestination.

@Test
public void testProcessBusinessObjectDataStatusChangeNotificationEventNoMessageDestination() throws Exception {
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper.createTestValidBusinessObjectData();
    // Get a business object data key.
    BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity);
    // Override configuration, so there will be no message definition specified in the relative notification message definition.
    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, NO_MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Try to trigger the notification.
    try {
        messageNotificationEventService.processBusinessObjectDataStatusChangeNotificationEvent(businessObjectDataKey, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.UPLOADING);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format("Notification message destination must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_DATA_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey()), e.getMessage());
    }
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectDataEntity(org.finra.herd.model.jpa.BusinessObjectDataEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) Test(org.junit.Test)

Example 7 with MessageHeaderDefinition

use of org.finra.herd.model.api.xml.MessageHeaderDefinition in project herd by FINRAOS.

the class DefaultNotificationMessageBuilderTest method testBuildStorageUnitStatusChangeMessagesJsonPayloadNoMessageType.

@Test
public void testBuildStorageUnitStatusChangeMessagesJsonPayloadNoMessageType() 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);
    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_STORAGE_UNIT_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_JSON, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Try to build a notification message.
    try {
        defaultNotificationMessageBuilder.buildStorageUnitStatusChangeMessages(businessObjectDataKey, STORAGE_NAME, STORAGE_UNIT_STATUS, STORAGE_UNIT_STATUS_2);
        fail();
    } catch (IllegalStateException illegalStateException) {
        assertEquals(String.format("Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_STORAGE_UNIT_STATUS_CHANGE_MESSAGE_DEFINITIONS.getKey()), illegalStateException.getMessage());
    }
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectDataKey(org.finra.herd.model.api.xml.BusinessObjectDataKey) AbstractServiceTest(org.finra.herd.service.AbstractServiceTest) Test(org.junit.Test)

Example 8 with MessageHeaderDefinition

use of org.finra.herd.model.api.xml.MessageHeaderDefinition in project herd by FINRAOS.

the class MessageNotificationEventServiceTest method testProcessBusinessObjectFormatVersionChangeNotificationEvent.

@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEvent() throws Exception {
    // Create a business object format entity.
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Get a business object data key.
    BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity);
    // Override configuration.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(MESSAGE_TYPE, MESSAGE_DESTINATION, BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Trigger the notification.
    List<NotificationMessage> result = messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);
    // Validate the results.
    assertEquals(1, CollectionUtils.size(result));
    businessObjectFormatServiceTestHelper.validateBusinessObjectFormatVersionChangeMessageWithXmlPayload(MESSAGE_TYPE, MESSAGE_DESTINATION, businessObjectFormatKey, HerdDaoSecurityHelper.SYSTEM_USER, businessObjectFormatKey.getBusinessObjectFormatVersion().toString(), NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION, Collections.singletonList(new MessageHeader(KEY, VALUE)), result.get(0));
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) NotificationMessage(org.finra.herd.model.dto.NotificationMessage) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) MessageHeader(org.finra.herd.model.dto.MessageHeader) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Example 9 with MessageHeaderDefinition

use of org.finra.herd.model.api.xml.MessageHeaderDefinition in project herd by FINRAOS.

the class MessageNotificationEventServiceTest method testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageType.

@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageType() throws Exception {
    // Create a business object format entity.
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Get a business object data key.
    BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity);
    // Override configuration, so there will be no message type specified in the relative notification message definition.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(NO_MESSAGE_TYPE, MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Try to trigger the notification.
    try {
        // Trigger the notification.
        messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format("Notification message type must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey()), e.getMessage());
    }
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Example 10 with MessageHeaderDefinition

use of org.finra.herd.model.api.xml.MessageHeaderDefinition in project herd by FINRAOS.

the class MessageNotificationEventServiceTest method testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageDestination.

@Test
public void testProcessBusinessObjectFormatVersionChangeNotificationEventNoMessageDestination() throws Exception {
    // Create a business object format entity.
    BusinessObjectDataInvalidateUnregisteredRequest request = new BusinessObjectDataInvalidateUnregisteredRequest(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, NO_SUBPARTITION_VALUES, StorageEntity.MANAGED_STORAGE);
    BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatServiceTestHelper.createBusinessObjectFormat(request);
    // Get a business object data key.
    BusinessObjectFormatKey businessObjectFormatKey = businessObjectFormatHelper.getBusinessObjectFormatKey(businessObjectFormatEntity);
    // Override configuration, so there will be no message definition specified in the relative notification message definition.
    ConfigurationEntity configurationEntity = new ConfigurationEntity();
    configurationEntity.setKey(ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey());
    configurationEntity.setValueClob(xmlHelper.objectToXml(new NotificationMessageDefinitions(Collections.singletonList(new NotificationMessageDefinition(MESSAGE_TYPE, NO_MESSAGE_DESTINATION, MESSAGE_TEXT, Collections.singletonList(new MessageHeaderDefinition(KEY, VALUE)))))));
    configurationDao.saveAndRefresh(configurationEntity);
    // Try to trigger the notification.
    try {
        // Trigger the notification.
        messageNotificationEventService.processBusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, NO_OLD_BUSINESS_OBJECT_FORMAT_VERSION);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format("Notification message destination must be specified. Please update \"%s\" configuration entry.", ConfigurationValue.HERD_NOTIFICATION_BUSINESS_OBJECT_FORMAT_VERSION_CHANGE_MESSAGE_DEFINITIONS.getKey()), e.getMessage());
    }
}
Also used : NotificationMessageDefinition(org.finra.herd.model.api.xml.NotificationMessageDefinition) NotificationMessageDefinitions(org.finra.herd.model.api.xml.NotificationMessageDefinitions) MessageHeaderDefinition(org.finra.herd.model.api.xml.MessageHeaderDefinition) BusinessObjectDataInvalidateUnregisteredRequest(org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest) ConfigurationEntity(org.finra.herd.model.jpa.ConfigurationEntity) BusinessObjectFormatKey(org.finra.herd.model.api.xml.BusinessObjectFormatKey) BusinessObjectFormatEntity(org.finra.herd.model.jpa.BusinessObjectFormatEntity) Test(org.junit.Test)

Aggregations

MessageHeaderDefinition (org.finra.herd.model.api.xml.MessageHeaderDefinition)13 NotificationMessageDefinition (org.finra.herd.model.api.xml.NotificationMessageDefinition)12 NotificationMessageDefinitions (org.finra.herd.model.api.xml.NotificationMessageDefinitions)12 ConfigurationEntity (org.finra.herd.model.jpa.ConfigurationEntity)9 Test (org.junit.Test)9 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)6 NotificationMessage (org.finra.herd.model.dto.NotificationMessage)6 ArrayList (java.util.ArrayList)4 MessageHeader (org.finra.herd.model.dto.MessageHeader)4 BusinessObjectDataEntity (org.finra.herd.model.jpa.BusinessObjectDataEntity)4 BusinessObjectDataInvalidateUnregisteredRequest (org.finra.herd.model.api.xml.BusinessObjectDataInvalidateUnregisteredRequest)3 BusinessObjectFormatKey (org.finra.herd.model.api.xml.BusinessObjectFormatKey)3 BusinessObjectFormatEntity (org.finra.herd.model.jpa.BusinessObjectFormatEntity)3 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)2