Ejemplo n.º 1
0
  @Test
  public void testDelete2() {

    dvdLibraryDao.create(dvd2);
    dvdLibraryDao.delete(dvd2.getId());

    int result = dvdLibraryDao.list().size();
    int expResult = 0;

    Assert.assertEquals(expResult, result);
  }
Ejemplo n.º 2
0
  @Test
  public void testCreate3() {

    dvdLibraryDao.create(dvd1);
    dvdLibraryDao.create(dvd2);
    dvdLibraryDao.create(dvd3);

    int result = dvdLibraryDao.list().size();
    int expResult = 3;

    Assert.assertEquals(expResult, result);
  }
Ejemplo n.º 3
0
  @Test
  public void testList2() {
    System.out.println("list");

    dvdLibraryDao.create(dvd1);
    dvdLibraryDao.create(dvd2);
    dvdLibraryDao.create(dvd3);

    int result = dvdLibraryDao.list().size();
    int expResult = 3;

    Assert.assertEquals(expResult, result);
  }
Ejemplo n.º 4
0
  @Test
  public void testList3() {

    dvdLibraryDao.create(dvd1);
    dvdLibraryDao.create(dvd2);
    dvdLibraryDao.create(dvd3);
    dvdLibraryDao.delete(dvd2.getId());

    List<Dvd> result = dvdLibraryDao.list();
    List<Dvd> expResult = new ArrayList<>();
    expResult.add(dvd1);
    expResult.add(dvd3);

    Assert.assertEquals(expResult, result);
  }
Ejemplo n.º 5
0
  /** Test of delete method, of class DvdLibraryDaoImpl. */
  @Test
  public void testDelete() {
    System.out.println("delete");

    dvdLibraryDao.create(dvd1);
    dvdLibraryDao.create(dvd2);
    dvdLibraryDao.create(dvd3);

    dvdLibraryDao.delete(dvd3.getId());

    int result = dvdLibraryDao.list().size();
    int expResult = 2;

    Assert.assertEquals(expResult, result);
  }
Ejemplo n.º 6
0
  /** Test of list method, of class DvdLibraryDaoImpl. */
  @Test
  public void testList() {
    System.out.println("list");

    dvdLibraryDao.create(dvd1);
    dvdLibraryDao.create(dvd2);
    dvdLibraryDao.create(dvd3);

    List<Dvd> result = dvdLibraryDao.list();
    List<Dvd> expResult = new ArrayList<>();

    expResult.add(dvd1);
    expResult.add(dvd2);
    expResult.add(dvd3);

    Assert.assertEquals(expResult, result);
  }
Ejemplo n.º 7
0
  @Before
  public void setUp() throws ParseException {
    while (!dvdLibraryDao.list().isEmpty()) {
      dvdLibraryDao.delete(dvdLibraryDao.list().get(0).getId());
    }

    sdf = new SimpleDateFormat("yyyy");
    date1 = sdf.parse("1999");
    date2 = sdf.parse("2000");
    date3 = sdf.parse("2001");
    date4 = sdf.parse("2002");
    date4a = sdf.parse("2001");
    date5 = sdf.parse("2003");

    note1a = new Note();
    note1b = new Note();
    note2a = new Note();
    note2b = new Note();
    note3a = new Note();
    note3b = new Note();
    note4a = new Note();
    note4b = new Note();
    note5a = new Note();
    note5b = new Note();

    note1a.setContent("Note1a");
    note1b.setContent("Note1b");
    note2a.setContent("Note2a");
    note2b.setContent("Note2b");
    note3a.setContent("Note3a");
    note3b.setContent("Note3b");

    note4a.setContent("Note4a");
    note4b.setContent("Note4b");
    note5a.setContent("Note5a");
    note5b.setContent("Note5b");

    dvd1 = new Dvd();
    dvd1.setNotes(new ArrayList<>());
    dvd2 = new Dvd();
    dvd2.setNotes(new ArrayList<>());
    dvd3 = new Dvd();
    dvd3.setNotes(new ArrayList<>());
    dvd4 = new Dvd();
    dvd4.setNotes(new ArrayList<>());
    dvd5 = new Dvd();
    dvd5.setNotes(new ArrayList<>());

    dvd1.setTitle("Title1");
    dvd1.setReleaseDate(date1);
    dvd1.setId(1);
    dvd1.setDirector("Director1");
    dvd1.setStudio("Studio1");
    dvd1.setMpaaRating("Rating1");
    dvd1.setUserRating(1);
    dvd1.getNotes().add(note1a);
    dvd1.getNotes().add(note1b);

    dvd2.setTitle("Title2");
    dvd2.setReleaseDate(date2);
    dvd2.setId(2);
    dvd2.setDirector("Director2");
    dvd2.setStudio("Studio2");
    dvd2.setMpaaRating("Rating2");
    dvd2.setUserRating(2);
    dvd2.getNotes().add(note2a);
    dvd2.getNotes().add(note2b);

    dvd3.setTitle("Title3");
    dvd3.setReleaseDate(date3);
    dvd3.setId(3);
    dvd3.setDirector("Director3");
    dvd3.setStudio("Studio3");
    dvd3.setMpaaRating("Rating3");
    dvd3.setUserRating(3);
    dvd3.getNotes().add(note3a);
    dvd3.getNotes().add(note3b);

    dvd4.setId(4);
    dvd4.setTitle("Title4");
    dvd4.setReleaseDate(date4);
    dvd4.setDirector("Director4");
    dvd4.setStudio("Studio4");
    dvd4.setMpaaRating("Rating4");
    dvd4.setUserRating(4);
  }