### Question:
UserHibernateDao extends GenericDao<JCUser> implements UserDao { @Override public User getCommonUserByUsername(String username) { return (User) session().getNamedQuery("getCommonUserByUsername") .setString("username", username).uniqueResult(); } UserHibernateDao(SessionFactory sessionFactory); @Override User getCommonUserByUsername(String username); @SuppressWarnings("unchecked") @Override JCUser getByUsername(String username); @Override JCUser getByEmail(String email); @SuppressWarnings("unchecked") @Override Collection<JCUser> getNonActivatedUsers(); @Override JCUser getByUuid(String uuid); @Override List<JCUser> getByUsernames(Set<String> usernames); @SuppressWarnings("unchecked") @Override List<String> getUsernames(String pattern, int count); @SuppressWarnings("unchecked") @Override List<JCUser> findByUsernameOrEmail(String pattern, int count); @Override JCUser loadById(Long id); @SuppressWarnings("unchecked") @Override List<UserDto> findByUsernameOrEmailNotInGroup(String pattern, long groupId, int count);  }### Answer:
@Test public void getCommonUserByUsernameShouldFindOne() { User expected = givenCommonUserWithUsernameStoredInDb("username"); User actual = userDao.getCommonUserByUsername("username"); assertNotNull(actual); assertReflectionEquals(actual, expected); }
@Test public void getCommonUserByUsernameShouldNotFind() { givenCommonUserWithUsernameStoredInDb("username"); User actual = userDao.getCommonUserByUsername("wrong username there is no such user"); assertNull(actual); }
@Test public void getCommonUserByUsernameShouldNotFindInEmptyDb() { User actual = userDao.getCommonUserByUsername("username"); assertNull(actual); }