### Question:
UserContactsHibernateDao extends GenericDao<UserContactType> implements UserContactsDao { @Override public UserContact getContactById(long id) { return (UserContact) session() .createQuery("from UserContact u where u.id = ?") .setCacheable(true) .setLong(0, id) .uniqueResult(); } UserContactsHibernateDao(SessionFactory sessionFactory); @Override List<UserContactType> getAvailableContactTypes(); @Override UserContact getContactById(long id);  }### Answer:
@Test public void testGetContactById() { UserContact contact = ObjectsFactory.getDefaultUserContact(); session.saveOrUpdate(contact.getOwner()); session.saveOrUpdate(contact.getType()); session.saveOrUpdate(contact); UserContact persisted = dao.getContactById(contact.getId()); assertEquals(contact, persisted); }
@Test public void testGetContactByWrongId() { UserContact persisted = dao.getContactById(5L); assertNull(persisted); }