@Test public void testPopulatePerson() { TestUtility.executeInserts(); // Paul is id 1 DBPerson paul = new DBPerson(); paul.setId(1); try { H2PersonDAO.getInstance().populatePerson(paul); } catch (PersonNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } assertTrue(paul.getName().equals("Paul Osborne")); assertTrue(paul.getAddress().equals("3001 Hampshire Ave N")); assertTrue(paul.getEmail().equals("*****@*****.**")); assertTrue(paul.getPhoneNumber().equals("7637970688")); }
@Test public void testGetOwnedMovies() { TestUtility.executeInserts(); DBPerson paul = new DBPerson(); paul.setId(1); try { H2PersonDAO.getInstance().populatePerson(paul); } catch (PersonNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<Movie> paulsMovies = H2PersonDAO.getInstance().getOwnedMovies(paul); ArrayList<String> movieStrings = new ArrayList<String>(); for (Movie m : paulsMovies) { movieStrings.add(m.getTitle()); } assertTrue(movieStrings.contains("Die Hard")); assertTrue(movieStrings.contains("Die Hard: With a Vengeance")); }