### Question:
SectionHibernateDao extends GenericDao<Section> implements SectionDao { @Override public List<Long> getAvailableBranchIds(JCUser user, List<Branch> branches) { if (branches.isEmpty()) { return Collections.emptyList(); } List<Long> branchIds = getEntityIdsLongs(new ArrayList<Entity>(branches)); if (!user.isAnonymous()) { return visibleBranchesForLoggedIn(user, branchIds); } Query query = session().getNamedQuery("getAvailableBranchesForAnonymousUser"); query.setParameterList("branchIds", branchIds); return query.list(); } SectionHibernateDao(SessionFactory sessionFactory); @Override @SuppressWarnings("unchecked") List<Section> getAll(); @Override List<Long> getAvailableBranchIds(JCUser user, List<Branch> branches); @Override long getCountAvailableBranches(JCUser user, List<Branch> branches);  }### Answer:
@Test public void getAvailableBranchIdsShouldReturnEmptyListForEmptyBranchList() { JCUser user = ObjectsFactory.getDefaultUser(); assertEquals(dao.getAvailableBranchIds(user, new ArrayList<org.jtalks.common.model.entity.Branch>()).size(), 0); }
@Test public void getAvailableBranchIdsShouldReturnEmptyListWhenUserHasNoGroupAssigned() { JCUser user = ObjectsFactory.getDefaultUser(); user.setGroups(new ArrayList<Group>()); List<Branch> branches = ObjectsFactory.getDefaultBranchList(); assertEquals(dao.getAvailableBranchIds(user, new ArrayList<org.jtalks.common.model.entity.Branch>(branches)).size(), 0); }
@Test public void getAvailableBranchIdsShouldReturnEmptyListWhenAnonymousUserHasNoGroupAssigned() { List<Branch> branches = ObjectsFactory.getDefaultBranchList(); assertEquals(dao.getAvailableBranchIds(new AnonymousUser(), new ArrayList<org.jtalks.common.model.entity.Branch>(branches)).size(), 0); }