NotificationServiceImpl implements NotificationService { public boolean matches(final Publisher p, final SubscriptionContext subscriptionContext) { if (!isPublisherValid(p)) { return false; } final boolean ok = (p.getResName().equals(subscriptionContext.getResName()) && p.getResId().equals(subscriptionContext.getResId()) && p.getSubidentifier() .equals(subscriptionContext.getSubidentifier())); return ok; } @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 matches_AnyValidPublisher() { Publisher anyPublisher = notificationWorld.getAnyPublisher(); SubscriptionContext subscriptionContext = notificationWorld.getSubscriptionContext(); boolean result = notificationService.matches(anyPublisher, subscriptionContext); assertFalse(result); }
@Test public void matches_NullPublisher() { SubscriptionContext subscriptionContext = notificationWorld.getSubscriptionContext(); boolean result = notificationService.matches(null, subscriptionContext); assertFalse(result); }
@Test(expected = RuntimeException.class) public void matches_NullSubscriptionContext() { Publisher thePublisher = notificationWorld.getThePublisher(); notificationService.matches(thePublisher, null); }
@Test public void matches_ThisContextPublisher() { Publisher thePublisher = notificationWorld.getThePublisher(); SubscriptionContext subscriptionContext = notificationWorld.getSubscriptionContext(); boolean result = notificationService.matches(thePublisher, subscriptionContext); assertTrue(result); }