UserNamespaceAuthorizationChangeMessageBuilder extends AbstractNotificationMessageBuilder implements NotificationMessageBuilder { @Override @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The NotificationEvent is cast to a UserNamespaceAuthorizationChangeNotificationEvent 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) { UserNamespaceAuthorizationChangeNotificationEvent event = (UserNamespaceAuthorizationChangeNotificationEvent) notificationEvent; Map<String, Object> velocityContextMap = new HashMap<>(); addObjectPropertyToContext(velocityContextMap, "userNamespaceAuthorizationKey", event.getUserNamespaceAuthorizationKey(), new UserNamespaceAuthorizationKey(escapeJson(event.getUserNamespaceAuthorizationKey().getUserId()), escapeJson(event.getUserNamespaceAuthorizationKey().getNamespace())), new UserNamespaceAuthorizationKey(escapeXml(event.getUserNamespaceAuthorizationKey().getUserId()), escapeXml(event.getUserNamespaceAuthorizationKey().getNamespace()))); addStringPropertyToContext(velocityContextMap, "namespace", event.getUserNamespaceAuthorizationKey().getNamespace()); return velocityContextMap; }  @Override @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The NotificationEvent is cast to a UserNamespaceAuthorizationChangeNotificationEvent 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 testgetUserNamespaceAuthorizationChangeMessageVelocityContextMap() { UserNamespaceAuthorizationKey userNamespaceAuthorizationKey = new UserNamespaceAuthorizationKey(USER_ID + SUFFIX_UNESCAPED, BDEF_NAMESPACE + SUFFIX_UNESCAPED); Map<String, Object> result = userNamespaceAuthorizationChangeMessageBuilder .getNotificationMessageVelocityContextMap(new UserNamespaceAuthorizationChangeNotificationEvent(userNamespaceAuthorizationKey)); UserNamespaceAuthorizationKey expectedUserNamespaceAuthorizationKeyWithJson = new UserNamespaceAuthorizationKey(USER_ID + SUFFIX_ESCAPED_JSON, BDEF_NAMESPACE + SUFFIX_ESCAPED_JSON); UserNamespaceAuthorizationKey expectedUserNamespaceAuthorizationKeyWithXml = new UserNamespaceAuthorizationKey(USER_ID + SUFFIX_ESCAPED_XML, BDEF_NAMESPACE + SUFFIX_ESCAPED_XML); assertEquals(6, CollectionUtils.size(result)); assertEquals(userNamespaceAuthorizationKey, result.get("userNamespaceAuthorizationKey")); assertEquals(expectedUserNamespaceAuthorizationKeyWithJson, result.get("userNamespaceAuthorizationKeyWithJson")); assertEquals(expectedUserNamespaceAuthorizationKeyWithXml, result.get("userNamespaceAuthorizationKeyWithXml")); 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")); }