### Question:
BannerHibernateDao extends GenericDao<Banner> implements BannerDao { @Override public Banner getByPosition(BannerPosition positionOnPage) { return (Banner) session().getNamedQuery("getByPosition") .setParameter("position", positionOnPage) .uniqueResult(); } BannerHibernateDao(SessionFactory sessionFactory); @Override Banner getByPosition(BannerPosition positionOnPage); @Override @SuppressWarnings("unchecked") Collection<Banner> getAll();  }### Answer:
@Test public void existsBannerShouldBeFoundByPosition() { Banner banner = ObjectsFactory.getDefaultBanner(); banner.setPositionOnPage(BannerPosition.TOP); session.save(banner); session.flush(); session.evict(banner); Banner bannerInDatabase = bannerDao.getByPosition(BannerPosition.TOP); assertNotNull(bannerInDatabase, "Banner should be found by position, because it was saved."); assertReflectionEquals(banner, bannerInDatabase); }
@Test public void existsBannerShouldNotBeFoundByPosition() { Banner banner = ObjectsFactory.getDefaultBanner(); banner.setPositionOnPage(BannerPosition.TOP); session.save(banner); session.flush(); session.evict(banner); Banner bannerInDatabase = bannerDao.getByPosition(BannerPosition.BOTTOM); assertNull(bannerInDatabase, "Banner shouldn't be found by position, because different banner was saved."); }