public void testCountByArticle() {
Blog blog = createBlog();
Article article1 = createArticle(blog);
Article article2 = createArticle(blog);
for (int i = 0; i < 10; i++) {
Comment comment = new Comment();
comment.setContent("comment " + i);
comment.setCreationDate(new Date());
comment.setArticle(article1);
comment.setUser(createUser());
commentDao.merge(comment);
}
for (int i = 10; i < 30; i++) {
Comment comment = new Comment();
comment.setContent("comment " + i);
comment.setCreationDate(new Date());
comment.setArticle(article2);
comment.setUser(createUser());
commentDao.merge(comment);
}
assertEquals("10 comments in article 1", commentDao.countByArticle(article1), 10);