### Question:
PrivateMessageHibernateDao extends GenericDao<PrivateMessage> implements PrivateMessageDao { @Override public int getNewMessagesCountFor(String username) { PrivateMessageStatus[] statuses = PrivateMessageStatus.getNewMessageStatus(); return ((Number) session().getNamedQuery("getNewMessagesCountFor") .setParameter("read", false) .setString("username", username) .setParameterList(STATUSES, statuses) .uniqueResult()) .intValue(); } PrivateMessageHibernateDao(SessionFactory sessionFactory); @SuppressWarnings("unchecked") @Override Page<PrivateMessage> getAllFromUser(JCUser userFrom, PageRequest pageRequest); @SuppressWarnings("unchecked") @Override Page<PrivateMessage> getAllForUser(JCUser userTo, PageRequest pageRequest); @SuppressWarnings("unchecked") @Override Page<PrivateMessage> getDraftsForUser(JCUser user, PageRequest pageRequest); @Override int getNewMessagesCountFor(String username); static final int DEFAULT_MESSAGE_COUNT; }### Answer:
@Test public void testGetNewMessagesCountFor() { saveMessagesWithDifferentStatus(); int count = dao.getNewMessagesCountFor(recipient.getUsername()); assertEquals(count, 1); }