### Question:
TransactionalSubscriptionService implements SubscriptionService { @Override public void subscribe(SubscriptionAwareEntity entityToSubscribe) { JCUser current = userService.getCurrentUser(); if (!(entityToSubscribe.getSubscribers().contains(current))) { entityToSubscribe.getSubscribers().add(current); saveChanges(entityToSubscribe); } } TransactionalSubscriptionService(UserService userService,
                                            BranchDao branchDao,
                                            TopicDao topicDao); @Override void toggleTopicSubscription(Topic topic); @Override void toggleBranchSubscription(Branch branch); @Override void unsubscribeFromBranch(Branch branch); @Override void toggleSubscription(SubscriptionAwareEntity entityToSubscribe); @Override Collection<JCUser> getAllowedSubscribers(SubscriptionAwareEntity entity); @Override void subscribe(SubscriptionAwareEntity entityToSubscribe);  }### Answer:
@Test public void testSubscribeIfUserIsNotSubscribedOnSubscriptionAwareEntity(){ service.subscribe(topic); assertTrue(topic.getSubscribers().contains(user)); verify(topicDao).saveOrUpdate(topic); }
@Test public void testSubscribeIfUserSubscribedOnSubscriptionAwareEntity(){ topic.getSubscribers().add(user); service.subscribe(topic); assertTrue(topic.getSubscribers().contains(user)); verify(topicDao,never()).saveOrUpdate(topic); }