StorageUnitStatusChangeMessageBuilder extends AbstractNotificationMessageBuilder implements NotificationMessageBuilder { @Override @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The NotificationEvent is cast to a StorageUnitStatusChangeNotificationEvent 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) { StorageUnitStatusChangeNotificationEvent event = (StorageUnitStatusChangeNotificationEvent) notificationEvent; Map<String, Object> velocityContextMap = new HashMap<>(); addObjectPropertyToContext(velocityContextMap, "businessObjectDataKey", event.getBusinessObjectDataKey(), escapeJsonBusinessObjectDataKey(event.getBusinessObjectDataKey()), escapeXmlBusinessObjectDataKey(event.getBusinessObjectDataKey())); addStringPropertyToContext(velocityContextMap, "storageName", event.getStorageName()); addStringPropertyToContext(velocityContextMap, "newStorageUnitStatus", event.getNewStorageUnitStatus()); addStringPropertyToContext(velocityContextMap, "oldStorageUnitStatus", event.getOldStorageUnitStatus()); addStringPropertyToContext(velocityContextMap, "namespace", event.getBusinessObjectDataKey().getNamespace()); return velocityContextMap; }  @Override @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The NotificationEvent is cast to a StorageUnitStatusChangeNotificationEvent 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 testGetStorageUnitStatusChangeMessageVelocityContextMap() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE + SUFFIX_UNESCAPED, BDEF_NAME + SUFFIX_UNESCAPED, FORMAT_USAGE_CODE + SUFFIX_UNESCAPED, FORMAT_FILE_TYPE_CODE + SUFFIX_UNESCAPED, FORMAT_VERSION, PARTITION_VALUE + SUFFIX_UNESCAPED, Lists .newArrayList(SUBPARTITION_VALUES.get(0) + SUFFIX_UNESCAPED, SUBPARTITION_VALUES.get(1) + SUFFIX_UNESCAPED, SUBPARTITION_VALUES.get(2) + SUFFIX_UNESCAPED, SUBPARTITION_VALUES.get(3) + SUFFIX_UNESCAPED), DATA_VERSION); Map<String, Object> result = storageUnitStatusChangeMessageBuilder.getNotificationMessageVelocityContextMap( new StorageUnitStatusChangeNotificationEvent(businessObjectDataKey, STORAGE_NAME + SUFFIX_UNESCAPED, STORAGE_UNIT_STATUS_2 + SUFFIX_UNESCAPED, STORAGE_UNIT_STATUS + SUFFIX_UNESCAPED)); BusinessObjectDataKey expectedBusinessObjectDataKeyWithJson = new BusinessObjectDataKey(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, PARTITION_VALUE + SUFFIX_ESCAPED_JSON, Lists .newArrayList(SUBPARTITION_VALUES.get(0) + SUFFIX_ESCAPED_JSON, SUBPARTITION_VALUES.get(1) + SUFFIX_ESCAPED_JSON, SUBPARTITION_VALUES.get(2) + SUFFIX_ESCAPED_JSON, SUBPARTITION_VALUES.get(3) + SUFFIX_ESCAPED_JSON), DATA_VERSION); BusinessObjectDataKey expectedBusinessObjectDataKeyWithXml = new BusinessObjectDataKey(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, PARTITION_VALUE + SUFFIX_ESCAPED_XML, Lists .newArrayList(SUBPARTITION_VALUES.get(0) + SUFFIX_ESCAPED_XML, SUBPARTITION_VALUES.get(1) + SUFFIX_ESCAPED_XML, SUBPARTITION_VALUES.get(2) + SUFFIX_ESCAPED_XML, SUBPARTITION_VALUES.get(3) + SUFFIX_ESCAPED_XML), DATA_VERSION); assertEquals(15, CollectionUtils.size(result)); assertEquals(businessObjectDataKey, result.get("businessObjectDataKey")); assertEquals(expectedBusinessObjectDataKeyWithJson, result.get("businessObjectDataKeyWithJson")); assertEquals(expectedBusinessObjectDataKeyWithXml, result.get("businessObjectDataKeyWithXml")); assertEquals(STORAGE_NAME + SUFFIX_UNESCAPED, result.get("storageName")); assertEquals(STORAGE_NAME + SUFFIX_ESCAPED_JSON, result.get("storageNameWithJson")); assertEquals(STORAGE_NAME + SUFFIX_ESCAPED_XML, result.get("storageNameWithXml")); assertEquals(STORAGE_UNIT_STATUS_2 + SUFFIX_UNESCAPED, result.get("newStorageUnitStatus")); assertEquals(STORAGE_UNIT_STATUS_2 + SUFFIX_ESCAPED_JSON, result.get("newStorageUnitStatusWithJson")); assertEquals(STORAGE_UNIT_STATUS_2 + SUFFIX_ESCAPED_XML, result.get("newStorageUnitStatusWithXml")); assertEquals(STORAGE_UNIT_STATUS + SUFFIX_UNESCAPED, result.get("oldStorageUnitStatus")); assertEquals(STORAGE_UNIT_STATUS + SUFFIX_ESCAPED_JSON, result.get("oldStorageUnitStatusWithJson")); assertEquals(STORAGE_UNIT_STATUS + SUFFIX_ESCAPED_XML, result.get("oldStorageUnitStatusWithXml")); 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")); }