/** Test of updatePerson method, of class H2PersonDAO. */ @Test public void testUpdatePerson() { TestUtility.executeInserts(); DBPerson p = new DBPerson(); p.setId(1); // Paul is person 1 p.setName("Some name that is not Paul"); p.setEmail("*****@*****.**"); p.setAddress("3899 drive"); p.setPhoneNumber("38828810083"); H2PersonDAO.getInstance().updatePerson(p); List<Person> people = H2PersonDAO.getInstance().getAllPersons(); ArrayList<String> names = new ArrayList<String>(); for (Person person : people) { names.add(person.getName()); } assertTrue(names.contains("Some name that is not Paul")); }
/** Test of addPerson method, of class H2PersonDAO. */ @Test public void testAddPerson() { TestUtility.executeInserts(); DBPerson p = new DBPerson(); p.setName("Bob Billy McTest"); p.setEmail("*****@*****.**"); p.setAddress("123 the lane"); p.setPhoneNumber("952.883.3918"); try { H2PersonDAO.getInstance().addPerson(p); } catch (PersonExistsException pee) { fail("Why was this thrown?"); } List<Person> people = H2PersonDAO.getInstance().getAllPersons(); ArrayList<String> names = new ArrayList<String>(); for (Person person : people) { names.add(person.getName()); } assertTrue(names.contains("Bob Billy McTest")); }