@Test public void getPublisher_PublisherExist() { when(subscriptionDelegateTestObject.publisherDao.findPublisher(contextId, contextType, sourceId, sourceType)).thenReturn(publisher); Publisher resultPublisher = subscriptionDelegateTestObject.getPublisher(subscriptionContext); assertEquals("getPublisher returns wrong publisher", publisher, resultPublisher); }
synchronized Publisher getPublisher(NotificationSubscriptionContext subscriptionContext) { Publisher publisher = publisherDao.findPublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType()); if (publisher == null) { publisher = publisherDao.createAndSavePublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType(), subscriptionContext.getSubcontextId()); } return publisher; }
SubscriptionDelegate { synchronized Publisher getPublisher(NotificationSubscriptionContext subscriptionContext) { Publisher publisher = publisherDao.findPublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType()); if (publisher == null) { publisher = publisherDao.createAndSavePublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType(), subscriptionContext.getSubcontextId()); } return publisher; } }
SubscriptionDelegate { synchronized Publisher getPublisher(NotificationSubscriptionContext subscriptionContext) { Publisher publisher = publisherDao.findPublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType()); if (publisher == null) { publisher = publisherDao.createAndSavePublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType(), subscriptionContext.getSubcontextId()); } return publisher; }  }
SubscriptionDelegate { synchronized Publisher getPublisher(NotificationSubscriptionContext subscriptionContext) { Publisher publisher = publisherDao.findPublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType()); if (publisher == null) { publisher = publisherDao.createAndSavePublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType(), subscriptionContext.getSubcontextId()); } return publisher; }  void deleteSubscription(NotificationSubscriptionContext subscriptionContext); void invalidateSubscriptionForSubscriptionContext(NotificationSubscriptionContext subscriptionContext); void invalidateSubscription(Publisher publisher, Subscriber subscriber); void invalidateSubscription(Subscription subscription); Subscription getSubscription(NotificationSubscriptionContext subscriptionContext); Subscription createAndSaveSubscription(NotificationSubscriptionContext subscriptionContext); List<Subscription> getSubscriptions(Identity identity); }
SubscriptionDelegate { synchronized Publisher getPublisher(NotificationSubscriptionContext subscriptionContext) { Publisher publisher = publisherDao.findPublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType()); if (publisher == null) { publisher = publisherDao.createAndSavePublisher(subscriptionContext.getContextId(), subscriptionContext.getContextType(), subscriptionContext.getSourceId(), subscriptionContext.getSourceType(), subscriptionContext.getSubcontextId()); } return publisher; }  void deleteSubscription(NotificationSubscriptionContext subscriptionContext); void invalidateSubscriptionForSubscriptionContext(NotificationSubscriptionContext subscriptionContext); void invalidateSubscription(Publisher publisher, Subscriber subscriber); void invalidateSubscription(Subscription subscription); Subscription getSubscription(NotificationSubscriptionContext subscriptionContext); Subscription createAndSaveSubscription(NotificationSubscriptionContext subscriptionContext); List<Subscription> getSubscriptions(Identity identity);  }