@Test public void testRegister() 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; } }; Notifier result = notificationService.register("test_notifier", mockCtx); assertEquals(mockNotifier, result); new Verifications() { { NotificationContext ctx; mockNotifier.open(ctx = withCapture()); times = 1; assertEquals(NotificationServiceContext.class, ctx.getClass()); } }; }
@Override public Notifier register(String notifierName, NotificationContext ctx) { LOG.info("Registering notifier name {}, NotificationContext {}", notifierName, ctx); Notifier notifier = loadNotifier(ctx.getConfig().getJarPath(), ctx.getConfig().getClassName()); Notifier registeredNotifier = notifiers.putIfAbsent(notifierName, notifier); if (registeredNotifier == null) { LOG.info("Initializing notifier"); notifier.open(new NotificationServiceContext(ctx, queueHandler, this)); registeredNotifier = notifier; } LOG.info("Notifier {} registered", notifierName); return registeredNotifier; }
NotificationServiceImpl implements NotificationService { @Override public Notifier register(String notifierName, NotificationContext ctx) { LOG.info("Registering notifier name {}, NotificationContext {}", notifierName, ctx); Notifier notifier = loadNotifier(ctx.getConfig().getJarPath(), ctx.getConfig().getClassName()); Notifier registeredNotifier = notifiers.putIfAbsent(notifierName, notifier); if (registeredNotifier == null) { LOG.info("Initializing notifier"); notifier.open(new NotificationServiceContext(ctx, queueHandler, this)); registeredNotifier = notifier; } LOG.info("Notifier {} registered", notifierName); return registeredNotifier; } }
NotificationServiceImpl implements NotificationService { @Override public Notifier register(String notifierName, NotificationContext ctx) { LOG.info("Registering notifier name {}, NotificationContext {}", notifierName, ctx); Notifier notifier = loadNotifier(ctx.getConfig().getJarPath(), ctx.getConfig().getClassName()); Notifier registeredNotifier = notifiers.putIfAbsent(notifierName, notifier); if (registeredNotifier == null) { LOG.info("Initializing notifier"); notifier.open(new NotificationServiceContext(ctx, queueHandler, this)); registeredNotifier = notifier; } LOG.info("Notifier {} registered", notifierName); return registeredNotifier; } NotificationServiceImpl();  NotificationServiceImpl(NotificationStore store);  NotificationServiceImpl(Map<String, Object> config);  NotificationServiceImpl(Map<String, Object> config, NotificationStore store); }
NotificationServiceImpl implements NotificationService { @Override public Notifier register(String notifierName, NotificationContext ctx) { LOG.info("Registering notifier name {}, NotificationContext {}", notifierName, ctx); Notifier notifier = loadNotifier(ctx.getConfig().getJarPath(), ctx.getConfig().getClassName()); Notifier registeredNotifier = notifiers.putIfAbsent(notifierName, notifier); if (registeredNotifier == null) { LOG.info("Initializing notifier"); notifier.open(new NotificationServiceContext(ctx, queueHandler, this)); registeredNotifier = notifier; } LOG.info("Notifier {} registered", notifierName); return registeredNotifier; } 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(); }
NotificationServiceImpl implements NotificationService { @Override public Notifier register(String notifierName, NotificationContext ctx) { LOG.info("Registering notifier name {}, NotificationContext {}", notifierName, ctx); Notifier notifier = loadNotifier(ctx.getConfig().getJarPath(), ctx.getConfig().getClassName()); Notifier registeredNotifier = notifiers.putIfAbsent(notifierName, notifier); if (registeredNotifier == null) { LOG.info("Initializing notifier"); notifier.open(new NotificationServiceContext(ctx, queueHandler, this)); registeredNotifier = notifier; } LOG.info("Notifier {} registered", notifierName); return registeredNotifier; } 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();  }