@Test public void getSubscriber_SubscripberMustBeCreated() { when(subscriptionDelegateTestObject.subscriberDao.findSubscriber(subscriberIdentity)).thenReturn(null); when(subscriptionDelegateTestObject.subscriberDao.createAndSaveSubscriber(subscriberIdentity)).thenReturn(subscriber); Subscriber resultSubscriber = subscriptionDelegateTestObject.getSubscriber(subscriberIdentity); assertEquals("getSubscriber returns wrong subscriber", subscriber, resultSubscriber); }
Subscriber getSubscriber(Identity subscriberIdentity) { Subscriber subscriber = subscriberDao.findSubscriber(subscriberIdentity); if (subscriber == null) { subscriber = subscriberDao.createAndSaveSubscriber(subscriberIdentity); } return subscriber; }
SubscriptionDelegate { Subscriber getSubscriber(Identity subscriberIdentity) { Subscriber subscriber = subscriberDao.findSubscriber(subscriberIdentity); if (subscriber == null) { subscriber = subscriberDao.createAndSaveSubscriber(subscriberIdentity); } return subscriber; } }
SubscriptionDelegate { Subscriber getSubscriber(Identity subscriberIdentity) { Subscriber subscriber = subscriberDao.findSubscriber(subscriberIdentity); if (subscriber == null) { subscriber = subscriberDao.createAndSaveSubscriber(subscriberIdentity); } return subscriber; }  }
SubscriptionDelegate { Subscriber getSubscriber(Identity subscriberIdentity) { Subscriber subscriber = subscriberDao.findSubscriber(subscriberIdentity); if (subscriber == null) { subscriber = subscriberDao.createAndSaveSubscriber(subscriberIdentity); } return subscriber; }  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 { Subscriber getSubscriber(Identity subscriberIdentity) { Subscriber subscriber = subscriberDao.findSubscriber(subscriberIdentity); if (subscriber == null) { subscriber = subscriberDao.createAndSaveSubscriber(subscriberIdentity); } return subscriber; }  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);  }