NotificationMessageManager { public List<NotificationMessage> buildNotificationMessages(NotificationEvent notificationEvent) { Assert.notNull(notificationEvent, "Parameter \"notificationEvent\" must not be null"); return eventTypeNotificationMessageBuilderMap.get(notificationEvent.getClass()).buildNotificationMessages(notificationEvent); }  @PostConstruct void populateEventTypeNotificationMessageBuilderMap(); Map<Class<?>, NotificationMessageBuilder> getEventTypeNotificationMessageBuilderMap(); List<NotificationMessage> buildNotificationMessages(NotificationEvent notificationEvent);  }
@Test public void testBuildNotificationMessagesNullNotificationEvent() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Parameter \"notificationEvent\" must not be null"); notificationMessageManager.buildNotificationMessages(null); }
@Test public void testBuildNotificationMessagesHappyPath() throws Exception { BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataServiceTestHelper .createTestValidBusinessObjectData(SUBPARTITION_VALUES, businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectDefinitionServiceTestHelper.getNewAttributes()); BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity); 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_SNS, MESSAGE_DESTINATION, BUSINESS_OBJECT_DATA_STATUS_CHANGE_NOTIFICATION_MESSAGE_VELOCITY_TEMPLATE_XML, NO_MESSAGE_HEADER_DEFINITIONS))))); configurationDao.saveAndRefresh(configurationEntity); List<NotificationMessage> result = notificationMessageManager.buildNotificationMessages( new BusinessObjectDataStatusChangeNotificationEvent(businessObjectDataKey, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.INVALID)); assertEquals(1, CollectionUtils.size(result)); businessObjectDataServiceTestHelper .validateBusinessObjectDataStatusChangeMessageWithXmlPayload(MESSAGE_TYPE_SNS, MESSAGE_DESTINATION, businessObjectDataKey, businessObjectDataEntity.getId(), HerdDaoSecurityHelper.SYSTEM_USER, BusinessObjectDataStatusEntity.VALID, BusinessObjectDataStatusEntity.INVALID, Collections.singletonList(new Attribute(ATTRIBUTE_NAME_3_MIXED_CASE, ATTRIBUTE_VALUE_3)), NO_MESSAGE_HEADERS, result.get(0)); }