*
* @throws Exception exception
*/
@Test
public void add() throws Exception {
final CommentRepository commentRepository = getCommentRepository();
final JSONObject comment = new JSONObject();
comment.put(Comment.COMMENT_CONTENT, "comment1 content");
comment.put(Comment.COMMENT_DATE, new Date());
comment.put(Comment.COMMENT_EMAIL, "test@gmail.com");
comment.put(Comment.COMMENT_NAME, "comment1 name");
comment.put(Comment.COMMENT_ON_ID, "comment1 on id");
comment.put(Comment.COMMENT_ON_TYPE, "comment1 on type");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
comment.put(Comment.COMMENT_SHARP_URL, "comment1 sharp url");
comment.put(Comment.COMMENT_URL, "comment1 url");
comment.put(Comment.COMMENT_THUMBNAIL_URL, "comment1 thumbnail url");
final Transaction transaction = commentRepository.beginTransaction();
commentRepository.add(comment);
transaction.commit();
final List<JSONObject> comments =
commentRepository.getComments("comment1 on id", 1,
Integer.MAX_VALUE);
Assert.assertNotNull(comments);
Assert.assertEquals(comments.size(), 1);
Assert.assertEquals(
commentRepository.getComments("not found", 1, Integer.MAX_VALUE).
size(), 0);
Assert.assertEquals(commentRepository.getRecentComments(3).size(), 1);
}