### Question:
TransactionalSubscriptionService implements SubscriptionService { @Override public void toggleTopicSubscription(Topic topic) { JCUser current = userService.getCurrentUser(); if (topic.userSubscribed(current)) { topic.getSubscribers().remove(current); } else { topic.getSubscribers().add(current); } topicDao.saveOrUpdate(topic); } 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 testTopicSubscription() { service.toggleTopicSubscription(topic); assertTrue(topic.getSubscribers().contains(user)); verify(topicDao).saveOrUpdate(topic); }
@Test public void testTopicUnsubscription() { topic.getSubscribers().add(user); service.toggleTopicSubscription(topic); assertFalse(topic.getSubscribers().contains(user)); verify(topicDao).saveOrUpdate(topic); }