/** * Returns Velocity context map of the keys and values common across all notification message types. * * @param username the username or user id of the logged in user that caused this message to be generated * @param herdEnvironmentKey the name of the herd environment property * @param herdEnvironmentValue the value of the herd environment property * @param herdNotificationSqsEnvironmentKey the name of the herd notification sqs environment property * @param herdNotificationSqsEnvironmentValue the value of the herd notification sqs environment property * * @return the Velocity context map */ Map<String, Object> getBaseVelocityContextMapHelper(String username, String herdEnvironmentKey, String herdEnvironmentValue, String herdNotificationSqsEnvironmentKey, String herdNotificationSqsEnvironmentValue) { Map<String, Object> context = new HashMap<>(); context.put(herdEnvironmentKey, herdEnvironmentValue); context.put(escapeJson(herdEnvironmentKey) + WITH_JSON_SNAKE_CASE, escapeJson(herdEnvironmentValue)); context.put(escapeXml(herdEnvironmentKey) + WITH_XML_SNAKE_CASE, escapeXml(herdEnvironmentValue)); context.put(herdNotificationSqsEnvironmentKey, herdNotificationSqsEnvironmentValue); context.put(escapeJson(herdNotificationSqsEnvironmentKey) + WITH_JSON_SNAKE_CASE, escapeJson(herdNotificationSqsEnvironmentValue)); context.put(escapeXml(herdNotificationSqsEnvironmentKey) + WITH_XML_SNAKE_CASE, escapeXml(herdNotificationSqsEnvironmentValue)); context.put("current_time", HerdDateUtils.now().toString()); context.put("uuid", UUID.randomUUID().toString()); addStringPropertyToContext(context, "username", username); context.put("StringUtils", StringUtils.class); context.put("CollectionUtils", CollectionUtils.class); context.put("Collections", Collections.class); // Return the message text. return context; }
/** * Returns Velocity context map of the keys and values common across all notification message types. * * @param username the username or user id of the logged in user that caused this message to be generated * @param herdEnvironmentKey the name of the herd environment property * @param herdEnvironmentValue the value of the herd environment property * @param herdNotificationSqsEnvironmentKey the name of the herd notification sqs environment property * @param herdNotificationSqsEnvironmentValue the value of the herd notification sqs environment property * * @return the Velocity context map */ Map<String, Object> getBaseVelocityContextMapHelper(String username, String herdEnvironmentKey, String herdEnvironmentValue, String herdNotificationSqsEnvironmentKey, String herdNotificationSqsEnvironmentValue) { Map<String, Object> context = new HashMap<>(); context.put(herdEnvironmentKey, herdEnvironmentValue); context.put(escapeJson(herdEnvironmentKey) + WITH_JSON_SNAKE_CASE, escapeJson(herdEnvironmentValue)); context.put(escapeXml(herdEnvironmentKey) + WITH_XML_SNAKE_CASE, escapeXml(herdEnvironmentValue)); context.put(herdNotificationSqsEnvironmentKey, herdNotificationSqsEnvironmentValue); context.put(escapeJson(herdNotificationSqsEnvironmentKey) + WITH_JSON_SNAKE_CASE, escapeJson(herdNotificationSqsEnvironmentValue)); context.put(escapeXml(herdNotificationSqsEnvironmentKey) + WITH_XML_SNAKE_CASE, escapeXml(herdNotificationSqsEnvironmentValue)); context.put("current_time", HerdDateUtils.now().toString()); context.put("uuid", UUID.randomUUID().toString()); addStringPropertyToContext(context, "username", username); context.put("StringUtils", StringUtils.class); context.put("CollectionUtils", CollectionUtils.class); context.put("Collections", Collections.class); // Return the message text. return context; }
jsonHelper.unmarshallJsonToObject(BusinessObjectDataStatusChangeJsonMessagePayload.class, notificationMessage.getMessageText()); assertEquals(StringUtils.length(businessObjectDataStatusChangeJsonMessagePayload.eventDate), StringUtils.length(HerdDateUtils.now().toString())); assertEquals(expectedBusinessObjectDataKey, businessObjectDataStatusChangeJsonMessagePayload.businessObjectDataKey); assertEquals(expectedNewBusinessObjectDataStatus, businessObjectDataStatusChangeJsonMessagePayload.newBusinessObjectDataStatus);
/** * Validates a business object data status change notification message with JSON payload. * * @param expectedMessageType the expected message type * @param expectedMessageDestination the expected message destination * @param expectedBusinessObjectFormatKey the expected business object format key * @param expectedNewBusinessObjectFormatVersion the expected new business object format version * @param expectedOldBusinessObjectFormatVersion the expected old business object format version * @param expectedMessageHeaders the list of expected message headers * @param notificationMessage the notification message to be validated */ private void validateBusinessObjectFormatVersionChangeMessageWithJsonPayload(String expectedMessageType, String expectedMessageDestination, BusinessObjectFormatKey expectedBusinessObjectFormatKey, String expectedNewBusinessObjectFormatVersion, String expectedOldBusinessObjectFormatVersion, List<MessageHeader> expectedMessageHeaders, NotificationMessage notificationMessage) throws IOException { assertNotNull(notificationMessage); assertEquals(expectedMessageType, notificationMessage.getMessageType()); assertEquals(expectedMessageDestination, notificationMessage.getMessageDestination()); BusinessObjectFormatVersionChangeJsonMessagePayload businessObjectFormatVersionChangeJsonMessagePayload = jsonHelper.unmarshallJsonToObject(BusinessObjectFormatVersionChangeJsonMessagePayload.class, notificationMessage.getMessageText()); assertEquals(StringUtils.length(businessObjectFormatVersionChangeJsonMessagePayload.eventDate), StringUtils.length(HerdDateUtils.now().toString())); assertEquals(expectedBusinessObjectFormatKey, businessObjectFormatVersionChangeJsonMessagePayload.businessObjectFormatKey); assertEquals(expectedNewBusinessObjectFormatVersion, businessObjectFormatVersionChangeJsonMessagePayload.newBusinessObjectFormatVersion); assertEquals(expectedOldBusinessObjectFormatVersion, businessObjectFormatVersionChangeJsonMessagePayload.oldBusinessObjectFormatVersion); assertEquals(expectedMessageHeaders, notificationMessage.getMessageHeaders()); }
/** * Validates a storage unit status change notification message with JSON payload. * * @param expectedMessageType the expected message type * @param expectedMessageDestination the expected message destination * @param expectedBusinessObjectDataKey the expected business object data key * @param expectedStorageName the expected storage name * @param expectedNewStorageUnitStatus the expected new business object data status * @param expectedOldStorageUnitStatus the expected old business object data status * @param expectedMessageHeaders the list of expected message headers * @param notificationMessage the notification message to be validated */ private void validateStorageUnitStatusChangeMessageWithJsonPayload(String expectedMessageType, String expectedMessageDestination, BusinessObjectDataKey expectedBusinessObjectDataKey, String expectedStorageName, String expectedNewStorageUnitStatus, String expectedOldStorageUnitStatus, List<MessageHeader> expectedMessageHeaders, NotificationMessage notificationMessage) throws IOException { assertNotNull(notificationMessage); assertEquals(expectedMessageType, notificationMessage.getMessageType()); assertEquals(expectedMessageDestination, notificationMessage.getMessageDestination()); StorageUnitStatusChangeJsonMessagePayload storageUnitStatusChangeJsonMessagePayload = jsonHelper.unmarshallJsonToObject(StorageUnitStatusChangeJsonMessagePayload.class, notificationMessage.getMessageText()); assertEquals(StringUtils.length(storageUnitStatusChangeJsonMessagePayload.eventDate), StringUtils.length(HerdDateUtils.now().toString())); assertEquals(expectedBusinessObjectDataKey, storageUnitStatusChangeJsonMessagePayload.businessObjectDataKey); assertEquals(expectedStorageName, storageUnitStatusChangeJsonMessagePayload.storageName); assertEquals(expectedNewStorageUnitStatus, storageUnitStatusChangeJsonMessagePayload.newStorageUnitStatus); assertEquals(expectedOldStorageUnitStatus, storageUnitStatusChangeJsonMessagePayload.oldStorageUnitStatus); assertEquals(expectedMessageHeaders, notificationMessage.getMessageHeaders()); }
StringUtils.length(HerdDateUtils.now().toString())); assertEquals(expectedBusinessObjectDefinitionDescriptionSuggestion.getBusinessObjectDefinitionDescriptionSuggestionKey(), businessObjectDefinitionDescriptionSuggestionChangeJsonMessagePayload.businessObjectDefinitionDescriptionSuggestionKey);