### Question:
TopicDraftHibernateDao extends GenericDao<TopicDraft> implements TopicDraftDao { @Override public TopicDraft getForUser(JCUser user) { Query query = session().getNamedQuery("getForUser") .setEntity("user", user); return (TopicDraft) query.uniqueResult(); } TopicDraftHibernateDao(SessionFactory sessionFactory); @Override TopicDraft getForUser(JCUser user); @Override void deleteByUser(JCUser user);  }### Answer:
@Test public void getForUserShouldReturnDraftIfUserHasOne() { JCUser user = PersistedObjectsFactory.getDefaultUser(); TopicDraft topicDraft = ObjectsFactory.getDefaultTopicDraft(); topicDraft.setTopicStarter(user); session.save(topicDraft); session.flush(); session.clear(); TopicDraft result = dao.getForUser(user); assertNotNull(result); assertReflectionEquals(user, result.getTopicStarter()); }
@Test public void getForUserShouldReturnNullIfUserHasNoDraft() { JCUser user = PersistedObjectsFactory.getDefaultUser(); session.flush(); session.clear(); assertNull(dao.getForUser(user)); }