use of org.mule.runtime.core.api.context.notification.NotificationsProvider in project mule by mulesoft.
the class ServerNotificationManagerConfiguratorTestCase method compliantDisabledNotificationByInterface.
@Test
public void compliantDisabledNotificationByInterface() throws InitialisationException {
doReturn(singletonList((NotificationsProvider) () -> singletonMap("test:COMPLIANT", new Pair(CompliantNotification.class, CompliantNotificationListener.class)))).when(registry).lookupAllByType(NotificationsProvider.class);
final DisabledNotificationConfig disableNotificationConfig = new DisabledNotificationConfig();
disableNotificationConfig.setInterfaceClass(CompliantNotificationListener.class);
configurator.setDisabledNotifications(singletonList(disableNotificationConfig));
configurator.initialise();
verify(notificationManager).disableInterface(CompliantNotificationListener.class);
}
use of org.mule.runtime.core.api.context.notification.NotificationsProvider in project mule by mulesoft.
the class ServerNotificationManagerConfiguratorTestCase method compliantDisabledNotificationByEventClass.
@Test
public void compliantDisabledNotificationByEventClass() throws InitialisationException {
doReturn(singletonList((NotificationsProvider) () -> singletonMap("test:COMPLIANT", new Pair(CompliantNotification.class, CompliantNotificationListener.class)))).when(registry).lookupAllByType(NotificationsProvider.class);
final DisabledNotificationConfig disableNotificationConfig = new DisabledNotificationConfig();
disableNotificationConfig.setEventClass(CompliantNotification.class);
configurator.setDisabledNotifications(singletonList(disableNotificationConfig));
configurator.initialise();
verify(notificationManager).disableType(CompliantNotification.class);
}
use of org.mule.runtime.core.api.context.notification.NotificationsProvider in project mule by mulesoft.
the class ServerNotificationManagerConfiguratorTestCase method compliantDisabledNotificationByEventName.
@Test
public void compliantDisabledNotificationByEventName() throws InitialisationException {
doReturn(singletonList((NotificationsProvider) () -> singletonMap("test:COMPLIANT", new Pair(CompliantNotification.class, CompliantNotificationListener.class)))).when(registry).lookupAllByType(NotificationsProvider.class);
final DisabledNotificationConfig disableNotificationConfig = new DisabledNotificationConfig();
disableNotificationConfig.setEventName("test:COMPLIANT");
configurator.setDisabledNotifications(singletonList(disableNotificationConfig));
configurator.initialise();
verify(notificationManager).disableType(CompliantNotification.class);
}
use of org.mule.runtime.core.api.context.notification.NotificationsProvider in project mule by mulesoft.
the class ServerNotificationManagerConfigurator method populateNotificationTypeMappings.
public ServerNotificationManager populateNotificationTypeMappings(Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException {
Map<String, NotificationsProvider> providersMap = new HashMap<>();
for (NotificationsProvider provider : registry.lookupAllByType(NotificationsProvider.class)) {
for (Entry<String, Pair<Class<? extends Notification>, Class<? extends NotificationListener>>> entry : provider.getEventListenerMapping().entrySet()) {
final String notificationType = entry.getKey();
if (!notificationType.matches("[a-zA-Z]+:[A-Z\\-]+")) {
throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' doesn't comply with the '[artifactID]:[NOTIFICATION-ID]' format", notificationType, provider.toString()), this);
}
if (eventMap.containsKey(notificationType)) {
throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' is already declared for another artifact in provider '%s'.", notificationType, provider.toString(), eventMap.get(notificationType)), this);
}
eventMap.put(notificationType, entry.getValue().getFirst());
interfaceMap.put(notificationType, entry.getValue().getSecond());
providersMap.put(notificationType, provider);
}
}
ServerNotificationManager notificationManager = muleContext.getNotificationManager();
if (dynamic != null) {
notificationManager.setNotificationDynamic(dynamic.booleanValue());
}
return notificationManager;
}
Aggregations