@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"); }
@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()); }