/** * Tests <code>{@link CopilotProjectDAOImpl#retrieveAll()}</code> method. * * @throws CopilotDAOException if any error occurs */ @Test public void testRetrieveAll2() throws CopilotDAOException { CopilotProfile copilotProfile1 = TestHelper.createCopilotProfile(); CopilotProject copilotProject1 = TestHelper.createCopilotProject(); TestHelper.persistCopilotProjectDependencies( hibernateTemplate, copilotProfile1, copilotProject1); hibernateTemplate.save(copilotProject1); CopilotProfile copilotProfile2 = TestHelper.createCopilotProfile(); CopilotProject copilotProject2 = TestHelper.createCopilotProject(); TestHelper.persistCopilotProjectDependencies( hibernateTemplate, copilotProfile2, copilotProject2); hibernateTemplate.save(copilotProject2); List<CopilotProject> result = instance.retrieveAll(); Assert.assertEquals("Two entities were expected.", 2, result.size()); assertCopilotProject(copilotProject1, result.get(0)); assertCopilotProject(copilotProject2, result.get(1)); hibernateTemplate.delete(copilotProject1); result = instance.retrieveAll(); Assert.assertEquals("One entity was expected.", 1, result.size()); assertCopilotProject(copilotProject2, result.get(0)); hibernateTemplate.delete(copilotProject2); Assert.assertEquals("No entities were expected.", 0, instance.retrieveAll().size()); }
/** * Tests <code>{@link CopilotProjectDAOImpl#retrieveAll()}</code> method. * * <p>{@link CopilotDAOException} is expected. * * @throws CopilotDAOException if any error occurs */ @Test(expected = CopilotDAOException.class) public void testRetrieveAllFailure2() throws CopilotDAOException { ApplicationContext applicationContext = new ClassPathXmlApplicationContext("invalidApplicationContext.xml"); CopilotProjectDAOImpl copilotProjectDAO = new CopilotProjectDAOImpl(); copilotProjectDAO.setSessionFactory( (SessionFactory) applicationContext.getBean("sessionFactory")); copilotProjectDAO.retrieveAll(); }
/** * Tests <code>{@link CopilotProjectDAOImpl#retrieveAll()}</code> method. * * @throws CopilotDAOException if any error occurs */ @Test public void testRetrieveAll3() throws CopilotDAOException { Assert.assertEquals("No entities were expected.", 0, instance.retrieveAll().size()); }