@Test @DatabaseSetup(PATH_TO_NEWS) public void testList() throws Exception { List<News> list = newsDAO.list(); Assert.assertNotNull(list); for (News news : list) { Assert.assertNotNull(news); if (news.getId() == 1L) { News newsExp = new News(); newsExp.setShortText("test short"); newsExp.setFullText("test full"); newsExp.setTitle("test title"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date = dateFormat.parse("01/01/2015 11:10:00"); newsExp.setCreationDate(date); newsExp.setModificationDate(new Timestamp(date.getTime())); newsExp.setId(1L); assertNews(newsExp, news); } } }
@Test @DatabaseSetup(PATH_TO_NEWS) public void testFetchById() throws Exception { News actual = newsDAO.fetchById(1L); Assert.assertNotNull(actual); News newsExp = new News(); newsExp.setShortText("test short"); newsExp.setFullText("test full"); newsExp.setTitle("test title"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date = dateFormat.parse("01/01/2015 11:10:00"); newsExp.setCreationDate(date); newsExp.setModificationDate(new Timestamp(date.getTime())); newsExp.setId(1L); assertNews(newsExp, actual); }
@Test @DatabaseSetup(PATH_TO_NEWS) public void testUpdate() throws Exception { News news = new News(); news.setId(3l); news.setShortText("new"); news.setFullText("new"); news.setTitle("new"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date date = dateFormat.parse("01/01/2015 11:10:00"); news.setCreationDate(date); news.setModificationDate(new Timestamp(date.getTime())); newsDAO.update(news); News actual = newsDAO.fetchById(3L); assertNews(news, actual); }