NotificationServiceImpl implements NotificationService { public NotificationsHandler getNotificationsHandler(final Publisher publisher) { final String type = publisher.getType(); if (notificationHandlers == null) { synchronized (lockObject) { if (notificationHandlers == null) { notificationHandlers = new HashMap<String, NotificationsHandler>(); if (notificationHandlersMap == null) { notificationHandlersMap = getNotificationHandlersMap(); } final Collection<Object> notificationsHandlerValues = notificationHandlersMap.values(); for (final Object object : notificationsHandlerValues) { final NotificationsHandler notificationsHandler = (NotificationsHandler) object; log.debug("initNotificationUpgrades notificationsHandler=" + notificationsHandler); notificationHandlers.put(notificationsHandler.getType(), notificationsHandler); } } } } return notificationHandlers.get(type); } @SuppressWarnings("unused") private  NotificationServiceImpl();   NotificationServiceImpl(final NotificationsDao notificationsManager, Map<String, Object> notificationHandlersMap,
            NotificationServiceStaticDependenciesWrapper staticDelegator); @Override List<SubscriptionInfo> getSubscriptionInfos(Identity identity, String publisherType); void notifyAllSubscribersByEmail(String title); @Override boolean sendMailToUserAndUpdateSubscriber(final Identity curIdent, final List<SubscriptionItem> items, String title, final List<Subscriber> subscribersToUpdate); @Override Subscriber getSubscriber(Long key); @Override Publisher getPublisher(SubscriptionContext subsContext); @Override List<Publisher> getAllPublisher(); void deletePublishersOf(final OLATResourceable ores); @Override Subscriber getSubscriber(Identity identity, Publisher publisher); @Override List<Subscriber> getSubscribers(Publisher publisher); @Override List<Identity> getSubscriberIdentities(Publisher publisher); @Override void markSubscriberRead(Identity identity, SubscriptionContext subsContext); @Override void markPublisherNews(SubscriptionContext subscriptionContext, Identity ignoreNewsFor); String getUserIntervalOrDefault(final Identity ident); Date getCompareDateFromInterval(final String interval); @Override boolean isSubscribed(Identity identity, SubscriptionContext subscriptionContext); @Override void delete(SubscriptionContext scontext); @Override void deactivate(Publisher publisher); @Override boolean isPublisherValid(Publisher pub); boolean matches(final Publisher p, final SubscriptionContext subscriptionContext); SubscriptionItem createSubscriptionItem(final Subscriber subscriber, final Locale locale, final String mimeTypeTitle, final String mimeTypeContent); SubscriptionItem createSubscriptionItem(final Subscriber subscriber, final Locale locale, final String mimeTypeTitle, final String mimeTypeContent,
            final Date latestEmailed); SubscriptionInfo getNoSubscriptionInfo(); void deleteUserData(final Identity identity, final String newDeletedUserName); @Override List<Subscriber> getSubscribers(Identity identity); @Override List<Subscriber> getValidSubscribers(Identity identity); @Override List<Subscriber> getValidSubscribersOf(Publisher publisher); @Override void subscribe(Identity identity, SubscriptionContext subscriptionContext, PublisherData publisherData); @Override void unsubscribe(Subscriber s); @Override void unsubscribe(Identity identity, SubscriptionContext subscriptionContext); NotificationsHandler getNotificationsHandler(final Publisher publisher); void setNotificationIntervals(final Map<String, Boolean> intervals); @Override List<String> getEnabledNotificationIntervals(); void setDefaultNotificationInterval(final String defaultNotificationInterval); String getDefaultNotificationInterval(); void registerAsListener(final GenericEventListener gel, final Identity ident); void deregisterAsListener(final GenericEventListener gel); @Override Translator getNotificationsTranslator(Identity identity);  }
@Test public void getNotificationsHandler_ForTheRightPublisher() { Publisher thePublisher = notificationWorld.getThePublisher(); NotificationsHandler notificationsHandler = notificationService.getNotificationsHandler(thePublisher); assertNotNull(notificationsHandler); }
@Test(expected = RuntimeException.class) public void getNotificationsHandler_ForNullPublisher() { notificationService.getNotificationsHandler(null); }