Exemplo n.º 1
0
 /** Test that a Comment instance can be created correctly. */
 public void testConstructionOfSimpleInstance() {
   assertNotNull(comment);
   assertEquals("Title", comment.getTitle());
   assertEquals("Body", comment.getBody());
   assertEquals("Author", comment.getAuthor());
   assertEquals("*****@*****.**", comment.getEmail());
   assertEquals("http://www.google.com", comment.getWebsite());
   assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar());
   assertEquals("127.0.0.1", comment.getIpAddress());
   assertNotNull(comment.getDate());
   assertEquals(comment.getDate().getTime(), comment.getId());
   assertNotNull(comment.getBlogEntry());
   assertEquals(State.APPROVED, comment.getState());
   assertEquals("c/" + comment.getBlogEntry().getId() + "/" + comment.getId(), comment.getGuid());
 }
Exemplo n.º 2
0
  public void testNestedCommentsAreUnindexedWhenParentDeleted() throws Exception {
    BlogService service = new BlogService();
    Comment comment2 =
        blogEntry.createComment(
            "Title",
            "Body",
            "Author",
            "*****@*****.**",
            "http://www.google.com",
            "http://graph.facebook.com/user/picture",
            "127.0.0.1");
    Comment comment3 =
        blogEntry.createComment(
            "Title",
            "Body",
            "Author",
            "*****@*****.**",
            "http://www.google.com",
            "http://graph.facebook.com/user/picture",
            "127.0.0.1");

    service.putBlogEntry(blogEntry);
    blogEntry.addComment(comment);

    comment2.setParent(comment);
    blogEntry.addComment(comment2);
    service.putBlogEntry(blogEntry);

    comment3.setParent(comment);
    blogEntry.addComment(comment3);
    service.putBlogEntry(blogEntry);

    assertTrue(blog.getResponseIndex().getPendingResponses().contains(comment.getGuid()));
    assertTrue(blog.getResponseIndex().getPendingResponses().contains(comment2.getGuid()));
    assertTrue(blog.getResponseIndex().getPendingResponses().contains(comment3.getGuid()));

    blogEntry.removeComment(comment.getId());
    service.putBlogEntry(blogEntry);

    assertFalse(blog.getResponseIndex().getPendingResponses().contains(comment.getGuid()));
    assertFalse(blog.getResponseIndex().getPendingResponses().contains(comment2.getGuid()));
    assertFalse(blog.getResponseIndex().getPendingResponses().contains(comment3.getGuid()));
  }