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

    DBMovie dieHard = new DBMovie();
    dieHard.setId(1);
  }
 @Before
 public void setUp() {
   // Get everything primed and ready to roll
   H2Util.getInstance().setDatabaseLocation("~/mangotesting.db");
   H2Util.getInstance().initializeSchemaOnDb();
   TestUtility.executeInserts();
 }
  @Test
  public void testRemoveList() {
    TestUtility.executeInserts();

    H2ListsDAO.getInstance().removeList("Action Marathon");
    assertTrue(H2ListsDAO.getInstance().getAllLists().size() == 0);
  }
  @Test
  public void testGetMoviesInList() {
    TestUtility.executeInserts();

    List<Movie> marathonMovies = H2ListsDAO.getInstance().getMoviesInList("Action Marathon");
    assertEquals("Die Hard", marathonMovies.get(0).getTitle());
    assertEquals("Die Hard: With a Vengeance", marathonMovies.get(1).getTitle());
  }
  @Test
  public void testGetAllLists() {
    TestUtility.executeInserts();

    List<String> lists = H2ListsDAO.getInstance().getAllLists();
    assertTrue(lists.size() == 1);
    assertTrue(lists.contains("Action Marathon"));
  }
  @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 testGetAllPersons() {
    TestUtility.executeInserts();

    List<Person> people = H2PersonDAO.getInstance().getAllPersons();
    String[] names = {"Paul Osborne", "Zachary Varberg", "Kyle Ronning"};
    List<String> namesList = Arrays.asList(names);
    for (Person p : people) {
      assertTrue(namesList.contains(p.getName()));
    }
  }
  @Test
  public void testReturnMovie() {
    // TODO: things still need to be sorted out with how borrower
    // ids are handles here and there.
    TestUtility.executeInserts();

    DBMovie dieHard = new DBMovie();
    dieHard.setId(1);
    dieHard.getTitle();
    H2PersonDAO.getInstance().returnMovie(dieHard);
    H2MovieDAO.getInstance().getMovieInfo(dieHard);
    assertTrue(dieHard.getBorrower() == null);
  }
  @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 testReorderMoviesInList() {
    TestUtility.executeInserts();

    // get the movies and reorder them
    List<Movie> movies = H2ListsDAO.getInstance().getMoviesInList("Action Marathon");
    ArrayList<Movie> newMoviesList = new ArrayList<Movie>();
    newMoviesList.add(movies.get(1));
    newMoviesList.add(movies.get(0));

    H2ListsDAO.getInstance().reorderMoviesInList("Action Marathon", newMoviesList);

    List<Movie> moviesAgain = H2ListsDAO.getInstance().getMoviesInList("Action Marathon");
    assertEquals("Die Hard: With a Vengeance", moviesAgain.get(0).getTitle());
    assertEquals("Die Hard", moviesAgain.get(1).getTitle());
  }
  @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"));
  }
  @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"));
  }