### Question:
HibernateSessionDAO extends HibernatePersistentObjectDAO<Session> implements SessionDAO { @Override public int countSessions(Long tenantId, Integer status) { StringBuffer query = new StringBuffer(" 1=1 "); if (tenantId != null) query.append(" and _entity.tenantId = " + tenantId); if (status != null) query.append(" and _entity.status = " + status); try { List<Session> sessions = findByWhere(query.toString(), null, null); return sessions.size(); } catch (PersistenceException e) { log.error(e.getMessage(), e); return 0; } } protected  HibernateSessionDAO(); @Override void deleteCurrentNodeSessions(); @Override int countSessions(Long tenantId, Integer status); @Override Session findBySid(String sid); @Override void initialize(Session session); @Override List<Session> findByNode(String node); @Override void cleanOldSessions(int ttl);  }### Answer:
@Test public void testCountSessions() { Assert.assertEquals(1, dao.countSessions(1L, Session.STATUS_OPEN)); Assert.assertEquals(1, dao.countSessions(null, Session.STATUS_OPEN)); Assert.assertEquals(1, dao.countSessions(1L, null)); Assert.assertEquals(1, dao.countSessions(null, null)); Assert.assertEquals(0, dao.countSessions(1L, Session.STATUS_CLOSED)); Assert.assertEquals(0, dao.countSessions(2L, Session.STATUS_OPEN)); }