Class CommunityClient

java.lang.Object
org.apache.sling.testing.clients.AbstractSlingClient
org.apache.sling.testing.clients.SlingClient
com.adobe.cq.testing.client.CQClient
com.adobe.cq.testing.client.CommunityClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.client.HttpClient

public class CommunityClient extends CQClient
The base client for all community related tests. It provides a core set of commonly used community functions e.g. comments

It extends from CQClient which in turn provides a core set of commonly used website and page functionality.
  • Constructor Details

    • CommunityClient

      public CommunityClient(org.apache.http.impl.client.CloseableHttpClient http, org.apache.sling.testing.clients.SlingClientConfig config) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • CommunityClient

      public CommunityClient(URI serverUrl, String user, String password) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
  • Method Details

    • addCommentsComponent

      public org.apache.sling.testing.clients.SlingHttpResponse addCommentsComponent(String pagePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Adds a Comment component to a page.
      Parameters:
      pagePath - path to the page where the comment component will be created.
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 201 (CREATED) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • configureCommentComponent

      public org.apache.sling.testing.clients.SlingHttpResponse configureCommentComponent(String commentPath, String defaultMessage, boolean isModerated, boolean allowReplies, boolean displayAsTree, boolean closed, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Configures the Comment component.
      Parameters:
      commentPath - path to the comment component
      defaultMessage - the topic for the comments
      isModerated - true if comments are moderated
      allowReplies - true if replies are allowed
      displayAsTree - true if the comments are displayed as tree
      closed - true if topic is closed (no posting of comments possible anymore)
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • moderateComment

      public org.apache.sling.testing.clients.SlingHttpResponse moderateComment(String commentPath, boolean approve, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Moderate comment: approve \ deny
      Parameters:
      commentPath - the path to the comment
      approve - true if comment should be approved, false if comment should be denied
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • markCommentAsSpam

      public org.apache.sling.testing.clients.SlingHttpResponse markCommentAsSpam(String commentPath, boolean isSpam, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Mark comment as spam
      Parameters:
      commentPath - the path to the comment
      isSpam - true if comment should be marked as spam, false if not
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • editComment

      public org.apache.sling.testing.clients.SlingHttpResponse editComment(String command, String commentPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Edit the comment: approve | deny | markCommentAsSpam | deleteComment
      Parameters:
      command - available commands: approve | deny | markCommentAsSpam | deleteComment
      commentPath - the path to the comment
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • createComment

      public com.fasterxml.jackson.databind.JsonNode createComment(String commentPath, String comment, String user, String url, String email, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Adds a single comment to a Comments component.
      Parameters:
      commentPath - path to the comment component
      comment - the comment text
      user - the user writing the comment
      url - the users url
      email - the users email
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      a JsonNode mapping to the requested content node.
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getComments

      public com.fasterxml.jackson.databind.JsonNode getComments(String ugcBasePath, int limit, int start, String predicate, String view) throws org.apache.sling.testing.clients.ClientException
      List all comments in the user generated content space, currently under /content/usergenerated.
      Parameters:
      ugcBasePath - The base path to start listing
      limit - limits the number of nodes below ugcBasePath to be returned
      start - defines the start node below ugcBasePath
      predicate - Predicate used to filter hierarchy nodes in the siteadmin e.g. siteadmin
      view - filter: null | approved | denied | spam | notspam
      Returns:
      a JsonNode mapping to the requested content node.
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • deleteComment

      public org.apache.sling.testing.clients.SlingHttpResponse deleteComment(String commentPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Delete comment
      Parameters:
      commentPath - The page where the comments are
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle