Package org.olat.core.commons.services.commentAndRating

Examples of org.olat.core.commons.services.commentAndRating.UserCommentsManager


   *      java.lang.String)
   */
  @Override
  protected UserCommentsManager createCommentManager(OLATResourceable ores,
      String subpath) {
    UserCommentsManager manager = new UserCommentsManagerImpl();
    manager.init(ores, subpath);
    return manager;
  }
View Full Code Here


    if (service == null) return;
    assertEquals(Long.valueOf(0), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(0), serviceWithSubPath.getUserCommentsManager().countComments());

    // add comments
    UserCommentsManager ucm = service.getUserCommentsManager();
    UserCommentsManager ucm2 = serviceWithSubPath.getUserCommentsManager();
   
    UserComment comment1 = ucm.createComment(ident1, "Hello World");
    UserComment comment2 = ucm2.createComment(ident1, "Hello World with subpath");
    // count must be 1 now. count without subpath should not include the results with subpath
    assertEquals(Long.valueOf(1), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(1), serviceWithSubPath.getUserCommentsManager().countComments());
    //
    UserComment comment3 = ucm.createComment(ident2, "Hello World");
    UserComment comment4 = ucm2.createComment(ident2, "Hello World with subpath");
    assertEquals(Long.valueOf(2), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(2), serviceWithSubPath.getUserCommentsManager().countComments());
    // Same with get method
    List<UserComment> commentList = ucm.getComments();
    assertEquals(2, commentList.size());
    List<UserComment> commentList2 = ucm2.getComments();
    assertEquals(2, commentList2.size());
    // Create a reply to the first comments
    ucm.replyTo(comment1, ident2, "Reply 1");
    ucm.replyTo(comment2, ident2, "Reply 1 with subpath");
    assertEquals(Long.valueOf(3), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(3), serviceWithSubPath.getUserCommentsManager().countComments());
    // Delete first created coment with one reply each
    ucm.deleteComment(comment1, true);
    ucm2.deleteComment(comment2, true);
    assertEquals(Long.valueOf(1), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(1), serviceWithSubPath.getUserCommentsManager().countComments());
    // Create reply to a comment that does not exis anymore -> should not create anything
    assertNull(ucm.replyTo(comment1, ident2, "Reply 1"));
    assertNull(ucm.replyTo(comment2, ident2, "Reply 1 with subpath"));
    // Recreate first comment
    comment1 = ucm.createComment(ident1, "Hello World");
    comment2 = ucm2.createComment(ident1, "Hello World with subpath");
    // Recreate a reply to the first comments
    ucm.replyTo(comment1, ident2, "Reply 1");
    ucm.replyTo(comment2, ident2, "Reply 1 with subpath");
    assertEquals(Long.valueOf(3), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(3), serviceWithSubPath.getUserCommentsManager().countComments());
    // Delete first created coment without the reply
    ucm.deleteComment(comment1, false);
    ucm2.deleteComment(comment2, false);
    assertEquals(Long.valueOf(2), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(2), serviceWithSubPath.getUserCommentsManager().countComments());
    // Delete all comments
    assertEquals(2, ucm.deleteAllComments());
    assertEquals(Long.valueOf(0), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(2), serviceWithSubPath.getUserCommentsManager().countComments());
    // Delete ignoring subpath
    comment1 = ucm.createComment(ident1, "Hello World");
    assertEquals(Long.valueOf(1), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(2), serviceWithSubPath.getUserCommentsManager().countComments());
    assertEquals(3, ucm2.deleteAllCommentsIgnoringSubPath());
    assertEquals(Long.valueOf(0), service.getUserCommentsManager().countComments());
    assertEquals(Long.valueOf(0), serviceWithSubPath.getUserCommentsManager().countComments());
  }
View Full Code Here

TOP

Related Classes of org.olat.core.commons.services.commentAndRating.UserCommentsManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.