@Test public void testGet3() { dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); Dvd result = dvdLibraryDao.get(dvd3.getId()); Dvd expResult = dvd3; Assert.assertEquals(expResult, result); }
@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); }
@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); }
/** Test of findOldestDvd method, of class DvdLibraryDaoImpl. */ @Test public void testFindOldestDvd() { System.out.println("findOldestDvd"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); Dvd result = dvdLibraryDao.findOldestDvd(); Dvd expResult = dvd1; Assert.assertEquals(expResult, result); }
/** Test of getAverageNumberOfNotes method, of class DvdLibraryDaoImpl. */ @Test public void testGetAverageNumberOfNotes() { System.out.println("getAverageNumberOfNotes"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); double result = dvdLibraryDao.getAverageNumberOfNotes(); double expResult = 2; Assert.assertEquals(expResult, result, 0); }
@Test public void testList4() { dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); dvdLibraryDao.delete(dvd2.getId()); int result = dvdLibraryDao.list().size(); int expResult = 2; Assert.assertEquals(expResult, result); }
@Test public void testSearchByTitle2() { dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); String title = "Title4"; List<Dvd> result = dvdLibraryDao.searchByTitle(title); List<Dvd> expResult = new ArrayList<>(); Assert.assertEquals(expResult, result); }
@Test public void testSearchNewerThanYear3() { System.out.println("searchNewerThanYear"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); int year = 2001; List<Dvd> result = dvdLibraryDao.searchNewerThanYear(year); List<Dvd> expResult = new ArrayList<>(); Assert.assertEquals(expResult, result); }
/** 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); }
@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); }
@Test public void testSearchByDirector4() { System.out.println("searchByDirector"); String director = "Director3"; dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); List<Dvd> result = dvdLibraryDao.searchByDirector(director); List<Dvd> expResult = new ArrayList<>(); expResult.add(dvd3); Assert.assertEquals(expResult, result); }
@Test public void testGetAverageNumberOfNotes2() { System.out.println("getAverageNumberOfNotes"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvd3.getNotes().add(note4a); dvd3.getNotes().add(note4b); dvdLibraryDao.create(dvd3); double result = dvdLibraryDao.getAverageNumberOfNotes(); double expResult = 2.6666666; Assert.assertEquals(expResult, result, 0.001); }
@Test public void testSearchByStudio4() { System.out.println("searchByStudio"); String studio = "Studio3"; dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); List<Dvd> result = dvdLibraryDao.searchByStudio(studio); List<Dvd> expResult = new ArrayList<>(); expResult.add(dvd3); Assert.assertEquals(expResult, result); }
@Test public void testSearchByMpaaRating3() { System.out.println("searchByMpaaRating"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); String rating = "Rating3"; List<Dvd> result = dvdLibraryDao.searchByMpaaRating(rating); List<Dvd> expResult = new ArrayList<>(); expResult.add(dvd3); assertEquals(expResult, result); }
/** 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); }
/** Test of getAverageAge method, of class DvdLibraryDaoImpl. */ @Test public void testGetAverageAge() { System.out.println("getAverageAge"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.create(dvd3); double result = Math.floor(dvdLibraryDao.getAverageAge()); double expResult = dvd1.getReleaseDate().toInstant().getEpochSecond(); expResult += dvd2.getReleaseDate().toInstant().getEpochSecond(); expResult += dvd3.getReleaseDate().toInstant().getEpochSecond(); expResult /= 3; expResult = new Date().toInstant().getEpochSecond() - expResult; expResult /= (3600 * 24); expResult = Math.floor(expResult); Assert.assertEquals(expResult, result, 0); }
/** Test of get method, of class DvdLibraryDaoImpl. */ @Test public void testGet() { System.out.println("get"); dvdLibraryDao.create(dvd1); Dvd result = dvdLibraryDao.get(dvd1.getId()); Dvd expResult = dvd1; Assert.assertEquals(expResult, result); }
@Test public void testUpdate4() { dvdLibraryDao.create(dvd4); dvdLibraryDao.get(dvd4.getId()).setStudio("Studio4Edit"); dvdLibraryDao.update(dvd4); String result = dvdLibraryDao.get(dvd4.getId()).getStudio(); String expResult = "Studio4Edit"; Assert.assertEquals(expResult, result); }
@Test public void testUpdate5() { dvdLibraryDao.create(dvd4); dvdLibraryDao.get(dvd4.getId()).setUserRating(5); dvdLibraryDao.update(dvd4); int result = dvdLibraryDao.get(dvd4.getId()).getUserRating(); int expResult = 5; Assert.assertEquals(expResult, result); }
@Test public void testUpdate6() { dvdLibraryDao.create(dvd4); dvdLibraryDao.get(dvd4.getId()).setReleaseDate(date4a); dvdLibraryDao.update(dvd4); Date result = dvdLibraryDao.get(dvd4.getId()).getReleaseDate(); Date expResult = date4a; Assert.assertEquals(expResult, result); }
@Test public void testUpdate3() { dvdLibraryDao.create(dvd4); dvdLibraryDao.get(dvd4.getId()).setDirector("Director4Edit"); dvdLibraryDao.update(dvd4); String result = dvdLibraryDao.get(dvd4.getId()).getDirector(); String expResult = "Director4Edit"; Assert.assertEquals(expResult, result); }
@Test public void testUpdate2() { dvdLibraryDao.create(dvd4); dvdLibraryDao.get(dvd4.getId()).setMpaaRating("Rating4Edit"); dvdLibraryDao.update(dvd4); String result = dvdLibraryDao.get(dvd4.getId()).getMpaaRating(); String expResult = "Rating4Edit"; Assert.assertEquals(expResult, result); }
/** Test of update method, of class DvdLibraryDaoImpl. */ @Test public void testUpdate() { System.out.println("update"); dvdLibraryDao.create(dvd4); dvdLibraryDao.get(dvd4.getId()).setTitle("Title4Edit"); dvdLibraryDao.update(dvd4); String result = dvdLibraryDao.get(dvd4.getId()).getTitle(); String expResult = "Title4Edit"; Assert.assertEquals(expResult, result); }
/** Test of searchByTitle method, of class DvdLibraryDaoImpl. */ @Test public void testSearchByTitle() { System.out.println("searchByTitle"); dvdLibraryDao.create(dvd1); dvdLibraryDao.create(dvd2); dvdLibraryDao.get(dvd2.getId()).setTitle("Title1"); dvdLibraryDao.update(dvd2); String title = "Title1"; List<Dvd> result = dvdLibraryDao.searchByTitle(title); List<Dvd> expResult = new ArrayList<>(); expResult.add(dvd1); expResult.add(dvd2); Assert.assertEquals(expResult, result); }
/** Test of create method, of class DvdLibraryDaoImpl. */ @Test public void testCreate1() { Dvd result = dvdLibraryDao.create(dvd1); Dvd expResult = dvd1; assertEquals(expResult, result); }