Class JsonClient

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.JsonClient
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.http.client.HttpClient

public class JsonClient extends CQClient
The base client for all json related tests. It provides a core set of commonly used json functions e.g. pages / versions / references...

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

    • JsonClient

      public JsonClient(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
    • JsonClient

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

    • getPages

      public com.fasterxml.jackson.databind.JsonNode getPages(String parentPath) throws org.apache.sling.testing.clients.ClientException
      Get children for a given page.
      Parameters:
      parentPath - parent page to get children from
      Returns:
      the root JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getPageReferences

      public com.fasterxml.jackson.databind.JsonNode getPageReferences(String[] pagePaths) throws org.apache.sling.testing.clients.ClientException
      Get all references used and its status in a given page
      In case path is not valid, an empty pages array will be returned
      Parameters:
      pagePaths - the page path to get the references for
      Returns:
      the root JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getMoveReferences

      public com.fasterxml.jackson.databind.JsonNode getMoveReferences(String pagePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Queries the list of page references for a given page, as it is used to display in the move dialog.
      Parameters:
      pagePath - the page path to get the references for
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      the root JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getLanguages

      public com.fasterxml.jackson.databind.JsonNode getLanguages(String sitePath, boolean deep) throws org.apache.sling.testing.clients.ClientException
      Get list of available languages for a page.
      In case path is not valid, an empty rows array will be returned
      Parameters:
      sitePath - the page path to get the languages for
      deep - true if languages' subpages should be part of json
      Returns:
      the root JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getVersions

      public com.fasterxml.jackson.databind.JsonNode getVersions(String pagePath, boolean showChildren, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Get versions for a given page
      Parameters:
      pagePath - the page path to get the versions for
      showChildren - true if versions of the children should be included
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
      Returns:
      the root JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getVersionTree

      public com.fasterxml.jackson.databind.JsonNode getVersionTree(String pagePath, String node, Date date, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Get version tree for a given page.
      Parameters:
      pagePath - the page path to get the version tree for
      node - the relative path to node
      date - the date which versions should be shown e.g. 2010-01-01T12:00:00+01:00
      expectedStatus - list of expected http status codes
      Returns:
      the root JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getUserGeneratedPages

      public com.fasterxml.jackson.databind.JsonNode getUserGeneratedPages(String ugcBasePath, int limit, int start, String predicate, String view) throws org.apache.sling.testing.clients.ClientException
      Get user generated pages in the user generated content (ucg) space, currently under /content/usergenerated.
      In case path is not valid, an empty pages array will be returned
      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 (nt:hierarchy- node, not hidden, no file
      view - filter: dependent from module
      Returns:
      a JsonNode mapping to the requested content node.
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle