### Question:
TopicHibernateDao extends GenericDao<Topic> implements TopicDao { @Override public List<Long> getForbiddenBranchesIds(JCUser user) { Query query = session().getNamedQuery("getForbiddenBranchesIds"); if (user.isAnonymous()) { query.setString("sid", user.getClass().getSimpleName()); } else { query.setParameterList("sid", getGroupIds(user)); } return query.list(); } TopicHibernateDao(SessionFactory sessionFactory); @Override Page<Topic> getTopicsUpdatedSince(DateTime timeStamp, PageRequest pageRequest, JCUser user); @Override Page<Topic> getUnansweredTopics(PageRequest pageRequest, JCUser user); @Override Topic getLastUpdatedTopicInBranch(Branch branch); @Override Page<Topic> getTopics(Branch branch, PageRequest pageRequest); @Override int countTopics(Branch branch); @Override Collection<JCUser> getAllowedSubscribers(SubscriptionAwareEntity entity); @Override List<Long> getForbiddenBranchesIds(JCUser user); @Override List<Long> getAllowedBranchesIds(JCUser user);  }### Answer:
@Test public void testGetForbiddenBranchesIdsWithAnonymousUser() { AnonymousUser user = new AnonymousUser(); PersistedObjectsFactory.createAndSaveViewTopicsBranchesEntity( ObjectsFactory.getDefaultBranch().getId(), user.getClass().getSimpleName(), false ); List<Long> collection = this.dao.getForbiddenBranchesIds(user); assertFalse(collection.isEmpty()); }
@Test public void testGetForbiddenBranchesIdsWithRealUser() { JCUser user = new JCUser("username", null, null); user.setGroups(ObjectsFactory.getDefaultGroupList()); PersistedObjectsFactory.createAndSaveViewTopicsBranchesEntity( ObjectsFactory.getDefaultBranch().getId(), String.valueOf(user.getGroups().get(0).getId()), false ); List<Long> collection = this.dao.getForbiddenBranchesIds(user); assertFalse(collection.isEmpty()); }