Ejemplo n.º 1
0
  @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);
      }
    }
  }
Ejemplo n.º 2
0
  @Before
  public void setUp() throws Exception {

    expectedNews = new News();
    expectedNews.setShortText("test short");
    expectedNews.setFullText("test full");
    expectedNews.setTitle("test title");
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    Date date = dateFormat.parse("01/01/2015 11:10:00");
    expectedNews.setCreationDate(date);
    expectedNews.setModificationDate(new Timestamp(date.getTime()));
  }
Ejemplo n.º 3
0
  @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);
  }
Ejemplo n.º 4
0
  @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);
  }