Example #1
0
 public void addComment(Comment comment) {
   if (!comment.isCommentSet()) {
     List<Comment> commentList = getComments();
     commentList.add(comment);
     comment.commentSet = true;
   }
 }
Example #2
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());
 }
Example #3
0
  @Test
  public void testFindNewsByComment() throws Exception {
    Comment comment = jpaCommentDao.getCommentById(1);

    List<Comment> commentList = new ArrayList();
    commentList.add(comment);

    News news = jpaNewsDao.getNewsById(1);
    news.setComments(commentList);

    Comment commentWithNews = jpaCommentDao.getCommentById(1);

    assertEquals(news, commentWithNews.getNews());
  }
Example #4
0
  @Test
  public void testCommentContainsComments() throws Exception {
    Comment parentComment = jpaCommentDao.getCommentById(1);

    Comment childComment1 = jpaCommentDao.getCommentById(2);
    Comment childComment2 = jpaCommentDao.getCommentById(3);

    parentComment.addComment(childComment1);
    parentComment.addComment(childComment2);

    entityTransactionComment.begin();
    jpaCommentDao.updateComment(parentComment);
    entityTransactionComment.commit();

    Comment newCom = jpaCommentDao.getCommentById(1);

    assertEquals(2, newCom.getComments().size());
  }
Example #5
0
  @Test
  public void testUpdateComment() throws Exception {
    Comment comment = jpaCommentDao.getCommentById(1);
    comment.setName("updatedName");
    Comment returnedComment = jpaCommentDao.updateComment(comment);
    Comment updatedComment = jpaCommentDao.getCommentById(1);

    assertEquals(returnedComment.getName(), "updatedName");
    assertEquals(updatedComment.getName(), "updatedName");
  }
Example #6
0
 @Test
 public void testGetCommentByName() throws Exception {
   Comment comment = jpaCommentDao.getCommentByName("commentName1");
   assertEquals(1, comment.getCommentId());
 }
Example #7
0
 @Test
 public void testCommentHaveUser() throws Exception {
   Comment comment = jpaCommentDao.getCommentById(1);
   assertEquals(User.class, comment.getUser().getClass());
 }
Example #8
0
 @Test
 public void testGetCommentById() throws Exception {
   Comment comment = jpaCommentDao.getCommentById(1);
   assertEquals(comment.getName(), "commentName1");
 }