SubscriptionDelegate { public Subscription createAndSaveSubscription(NotificationSubscriptionContext subscriptionContext) { Publisher publisher = getPublisher(subscriptionContext); Subscriber subscriber = getSubscriber(subscriptionContext.getIdentity()); return subscriptionDao.createOrReuseSubscription(subscriber, publisher); }  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);  }
@Test public void createAndSaveSubscription() { when(subscriptionDelegateTestObject.subscriptionDao.createOrReuseSubscription(subscriber, publisher)).thenReturn(subscription); Subscription createdSubscription = subscriptionDelegateTestObject.createAndSaveSubscription(subscriptionContext); assertEquals("createAndSaveSubscription returns wrong subscription", subscription, createdSubscription); }