Beispiel #1
0
 @Test
 public void testCreateComment() throws Exception {
   Comment comment = new Comment("Comment name", "Article name");
   entityTransactionComment.begin();
   Comment returned = jpaCommentDao.createComment(comment);
   entityTransactionComment.commit();
   assertEquals(4, returned.getCommentId());
 }
Beispiel #2
0
  @Test
  public void testGetSortedListOnDate() throws Exception {
    Comment comment1 = new Comment("Some1", "comment1");
    Comment comment2 = new Comment("Some2", "comment2");
    Comment comment3 = new Comment("Some3", "comment3");

    entityTransactionComment.begin();
    jpaCommentDao.createComment(comment2);
    jpaCommentDao.createComment(comment1);
    jpaCommentDao.createComment(comment3);
    entityTransactionComment.commit();

    List<Comment> comments = jpaCommentDao.getAllCommentsSortedOnDate();

    assertEquals(comments.get(3).getName(), "Some2");
    assertEquals(comments.get(4).getName(), "Some1");
    assertEquals(comments.get(5).getName(), "Some3");
  }