@Override public void pluginLoaded(GoPluginDescriptor pluginDescriptor) { if (notificationExtension.canHandlePlugin(pluginDescriptor.id())) { try { notificationPluginRegistry.registerPlugin(pluginDescriptor.id()); List<String> notificationsInterestedIn = notificationExtension.getNotificationsOfInterestFor(pluginDescriptor.id()); if (notificationsInterestedIn != null && !notificationsInterestedIn.isEmpty()) { checkNotificationTypes(pluginDescriptor, notificationsInterestedIn); notificationPluginRegistry.registerPluginInterests(pluginDescriptor.id(), notificationsInterestedIn); } } catch (Exception e) { LOGGER.warn("Error occurred during plugin notification interest registration.", e); } } }
@Test public void shouldNotRegisterDuplicatePlugins() { notificationPluginRegistry.registerPlugin("plugin_id_1"); notificationPluginRegistry.registerPlugin("plugin_id_1"); assertThat(notificationPluginRegistry.getNotificationPlugins().size(), is(1)); assertTrue(notificationPluginRegistry.getNotificationPlugins().contains("plugin_id_1")); }
@Test public void shouldListRegisteredPlugins() { notificationPluginRegistry.registerPlugin("plugin_id_1"); notificationPluginRegistry.registerPlugin("plugin_id_2"); assertThat(notificationPluginRegistry.getNotificationPlugins().size(), is(2)); assertTrue(notificationPluginRegistry.getNotificationPlugins().contains("plugin_id_1")); assertTrue(notificationPluginRegistry.getNotificationPlugins().contains("plugin_id_2")); }
@Test public void shouldRegisterPluginOnPluginLoad() { NotificationPluginRegistrar notificationPluginRegistrar = new NotificationPluginRegistrar(pluginManager, notificationExtension, notificationPluginRegistry); notificationPluginRegistrar.pluginLoaded(new GoPluginDescriptor(PLUGIN_ID_1, null, null, null, null, true)); verify(notificationPluginRegistry).registerPlugin(PLUGIN_ID_1); }
@Test public void shouldNotListDeRegisteredPlugins() { notificationPluginRegistry.registerPlugin("plugin_id_1"); notificationPluginRegistry.deregisterPlugin("plugin_id_1"); assertTrue(notificationPluginRegistry.getNotificationPlugins().isEmpty()); } }