### Question:
BranchHibernateDao extends GenericDao<Branch> implements BranchDao { @Override public int getCountPostsInBranch(Branch branch) { Number count = (Number) session() .getNamedQuery("getCountPostsInBranch") .setParameter("branch", branch) .uniqueResult(); return count.intValue(); } BranchHibernateDao(SessionFactory sessionFactory); @SuppressWarnings("unchecked") @Override List<Branch> getAllBranches(); @Override int getCountPostsInBranch(Branch branch); @Override Collection<JCUser> getAllowedSubscribers(SubscriptionAwareEntity entity);  }### Answer:
@Test public void testGetCountPostsInBranch() { Topic topic = PersistedObjectsFactory.getDefaultTopic(); Branch branch = topic.getBranch(); topic.addPost(new Post(topic.getTopicStarter(), "Second post")); topic.addPost(new Post(topic.getTopicStarter(), "Third post")); session.save(branch); int expectedCount = topic.getPosts().size(); int actualCount = dao.getCountPostsInBranch(branch); assertEquals(actualCount, expectedCount, "Count of posts in the branch is wrong"); }