NotificationServiceImpl implements NotificationService { @Override public Future<?> notify(String notifierName, Notification notification) { LOG.debug("Notify notifierName {}, notification {}", notifierName, notification); notificationStore.ifPresent(s -> s.store(notification)); Notifier notifier = notifiers.get(notifierName); if (notifier == null) { throw new NoSuchNotifierException("Notifier not found for id " + notification.getNotifierName()); } return queueHandler.enqueue(notifier, notification); } NotificationServiceImpl();  NotificationServiceImpl(NotificationStore store);  NotificationServiceImpl(Map<String, Object> config);  NotificationServiceImpl(Map<String, Object> config, NotificationStore store); @Override Notifier register(String notifierName, NotificationContext ctx); @Override Notifier remove(String notifierName); @Override Future<?> notify(String notifierName, Notification notification); @Override Notification getNotification(String notificationId); @Override List<Notification> getNotifications(List<String> notificationIds); @Override List<Notification> findNotifications(List<QueryParam> queryParams); @Override StreamlineEvent getEvent(String eventId); @Override List<StreamlineEvent> getEvents(List<String> eventIds); @Override Notification updateNotificationStatus(String notificationId, Notification.Status status); @Override void close();  }
@Test public void testNotify() throws Exception { new Expectations() { { mockCtx.getConfig(); times = 3; result = mockNotifierConfig; mockNotifierConfig.getClassName(); times = 1; result = "Test"; mockNotifierConfig.getJarPath(); times = 1; result = "/tmp/test.jar"; mockProxyUtil.loadClassFromJar("/tmp/test.jar", "Test"); result = mockNotifier; mockNotification.getId(); times = 1; result = "123"; } }; notificationService.register("test_notifier", mockCtx); Future<?> res = notificationService.notify("test_notifier", mockNotification); res.get(5, TimeUnit.SECONDS); new Verifications() { { mockNotificationStore.store(mockNotification); times = 1; mockNotifier.notify(mockNotification); times = 1; } }; }
@Test(expected = NoSuchNotifierException.class) public void testNotifyWithoutNotifier() { notificationService.notify("foo_notifier", mockNotification); }