BusinessObjectFormatVersionChangeMessageBuilder extends AbstractNotificationMessageBuilder implements NotificationMessageBuilder { @Override @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The NotificationEvent is cast to a BusinessObjectFormatVersionChangeNotificationEvent which is always the case since" + " we manage the event type to a builder in a map defined in NotificationMessageManager") public Map<String, Object> getNotificationMessageVelocityContextMap(NotificationEvent notificationEvent) { BusinessObjectFormatVersionChangeNotificationEvent event = (BusinessObjectFormatVersionChangeNotificationEvent) notificationEvent; Map<String, Object> velocityContextMap = new HashMap<>(); addObjectPropertyToContext(velocityContextMap, "businessObjectFormatKey", event.getBusinessObjectFormatKey(), escapeJsonBusinessObjectFormatKey(event.getBusinessObjectFormatKey()), escapeXmlBusinessObjectFormatKey(event.getBusinessObjectFormatKey())); velocityContextMap.put("newBusinessObjectFormatVersion", event.getBusinessObjectFormatKey().getBusinessObjectFormatVersion()); velocityContextMap.put("oldBusinessObjectFormatVersion", event.getOldBusinessObjectFormatVersion()); addStringPropertyToContext(velocityContextMap, "namespace", event.getBusinessObjectFormatKey().getNamespace()); return velocityContextMap; }  @Override @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The NotificationEvent is cast to a BusinessObjectFormatVersionChangeNotificationEvent which is always the case since" + " we manage the event type to a builder in a map defined in NotificationMessageManager") Map<String, Object> getNotificationMessageVelocityContextMap(NotificationEvent notificationEvent);  }
@Test public void testGetBusinessObjectFormatVersionChangeMessageVelocityContextMap() { BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE + SUFFIX_UNESCAPED, BDEF_NAME + SUFFIX_UNESCAPED, FORMAT_USAGE_CODE + SUFFIX_UNESCAPED, FORMAT_FILE_TYPE_CODE + SUFFIX_UNESCAPED, FORMAT_VERSION_2); Map<String, Object> result = businessObjectFormatVersionChangeMessageBuilder.getNotificationMessageVelocityContextMap( new BusinessObjectFormatVersionChangeNotificationEvent(businessObjectFormatKey, String.valueOf(FORMAT_VERSION))); BusinessObjectFormatKey expectedBusinessObjectFormatKeyWithJson = new BusinessObjectFormatKey(BDEF_NAMESPACE + SUFFIX_ESCAPED_JSON, BDEF_NAME + SUFFIX_ESCAPED_JSON, FORMAT_USAGE_CODE + SUFFIX_ESCAPED_JSON, FORMAT_FILE_TYPE_CODE + SUFFIX_ESCAPED_JSON, FORMAT_VERSION_2); BusinessObjectFormatKey expectedBusinessObjectFormatKeyWithXml = new BusinessObjectFormatKey(BDEF_NAMESPACE + SUFFIX_ESCAPED_XML, BDEF_NAME + SUFFIX_ESCAPED_XML, FORMAT_USAGE_CODE + SUFFIX_ESCAPED_XML, FORMAT_FILE_TYPE_CODE + SUFFIX_ESCAPED_XML, FORMAT_VERSION_2); assertEquals(8, CollectionUtils.size(result)); assertEquals(businessObjectFormatKey, result.get("businessObjectFormatKey")); assertEquals(expectedBusinessObjectFormatKeyWithJson, result.get("businessObjectFormatKeyWithJson")); assertEquals(expectedBusinessObjectFormatKeyWithXml, result.get("businessObjectFormatKeyWithXml")); assertEquals(FORMAT_VERSION_2, result.get("newBusinessObjectFormatVersion")); assertEquals(FORMAT_VERSION.toString(), result.get("oldBusinessObjectFormatVersion")); assertEquals(BDEF_NAMESPACE + SUFFIX_UNESCAPED, result.get("namespace")); assertEquals(BDEF_NAMESPACE + SUFFIX_ESCAPED_JSON, result.get("namespaceWithJson")); assertEquals(BDEF_NAMESPACE + SUFFIX_ESCAPED_XML, result.get("namespaceWithXml")); }