@Test
  public void testGetBorrowedMovies() {
    TestUtility.executeInserts();

    DBPerson zach = new DBPerson();
    zach.setId(2);
    List<Movie> movies = H2PersonDAO.getInstance().getBorrowedMovies(zach);
    assertTrue(movies.size() == 1);
    assertTrue(movies.get(0).getTitle().equals("Die Hard: With a Vengeance"));
  }
  @Test
  public void testBorrowMovie() {
    TestUtility.executeInserts();

    // setup people and movie
    DBPerson kyle = new DBPerson();
    kyle.setId(3);
    DBMovie dieHard = new DBMovie();
    dieHard.setId(1);

    // borrow die hard to kyle
    H2PersonDAO.getInstance().borrowMovie(kyle, dieHard);
    H2MovieDAO.getInstance().updateMovie(dieHard);

    assertTrue(((DBPerson) dieHard.getBorrower()).getId() == kyle.getId());
  }
  @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"));
  }
  /** 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"));
  }
  @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 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"));
  }