AbstractListener implements EventListener<T> { @Override public final void handle(final T event, final SessionInfo sessionInfo) { try { if (!this.shouldNotify(event, sessionInfo)) { logger.debug("Will not notify."); } else { logger.debug("Notifying {}.", event); handler.offer(createSubmission(event, sessionInfo)); } } catch (final Exception ex) { throw new IllegalStateException("Event processing failed.", ex); } finally { try { finish(event, sessionInfo); } catch (final Exception ex) { logger.trace("Finisher failed.", ex); } finally { logger.debug("Notified {}.", event); } } } protected  AbstractListener(final SupportedListener listener, final AbstractTargetHandler handler); abstract String getSubject(final T event); abstract String getTemplateFileName(); final Map<String, Object> getData(final T event, final SessionInfo sessionInfo); @Override final void handle(final T event, final SessionInfo sessionInfo);  }
@Test void spamProtectionAvailable() throws Exception { final ConfigStorage cs = ConfigStorage .create(getClass().getResourceAsStream("notifications-enabled-spamless.cfg")); final AbstractTargetHandler p = getHandler(cs); final TestingEmailingListener l = new TestingEmailingListener(p); l.handle(EVENT, SESSION); verify(p, times(1)).send(notNull(), notNull(), notNull(), notNull()); l.handle(EVENT, SESSION); verify(p, times(1)).send(notNull(), notNull(), notNull(), notNull()); }