Class TagClient

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

public class TagClient extends CQClient
The base client for all tag related tests. It provides a core set of commonly used tag functions e.g. create / edit / delete

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

    • TAG_COMMAND_PATH

      public static final String TAG_COMMAND_PATH
      See Also:
    • TAG_RESOURCE_PATH

      public static final String TAG_RESOURCE_PATH
      See Also:
    • TAG_GARBAGE_COLLECTOR_DEFAULT_CRON_EXPRESSION

      public static String TAG_GARBAGE_COLLECTOR_DEFAULT_CRON_EXPRESSION
    • TAG_GARBAGE_COLLECTOR_CRON_EXPRESSION_PROP

      public static String TAG_GARBAGE_COLLECTOR_CRON_EXPRESSION_PROP
  • Constructor Details

    • TagClient

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

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

    • addTagCloudComponent

      public org.apache.sling.testing.clients.SlingHttpResponse addTagCloudComponent(String pageHandle, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Adds a TagCloud Component to a page.
      Parameters:
      pageHandle - handle of the page that will get a tag cloud component added
      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
    • editTagCloudComponent

      public org.apache.sling.testing.clients.SlingHttpResponse editTagCloudComponent(String componentPath, boolean showAsLink, String path, String display, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Edits the TagCloud component.
      Parameters:
      componentPath - the components path
      showAsLink - true if tags should have link tags (execute a search for the tag)
      path - optional, path of the page, the display values 'page' and 'pagetree' relate to.
      display - what should be rendered:
      • page: show only tags of this page or the page referenced in path
      • pagetree: show tags of this page and sub pages or the refrenced page in path and its according subpages
      • all: show all tags set in the site
      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
    • canCreateTag

      public org.apache.sling.testing.clients.SlingHttpResponse canCreateTag(String tagId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Checks if user can create a specific Tag
      Parameters:
      tagId - tag ID. mandatory.
      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
    • canCreateTagByTitle

      public org.apache.sling.testing.clients.SlingHttpResponse canCreateTagByTitle(String tagId, String locale, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Checks if user can create a specific Tag based on title
      Parameters:
      tagId - tag ID. mandatory.
      locale - i18n locale code.
      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
    • createTag

      public org.apache.sling.testing.clients.SlingHttpResponse createTag(String tagTitle, String tagId, String tagDescr, String parentTagId, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Adds a tag
      Parameters:
      tagTitle - title of the Tag. mandatory.
      tagId - tag ID. mandatory.
      tagDescr - description of the tag. Set null if not used.
      parentTagId - parent tag ID. Set null if not used. E.g. stockphotography:animals/birds/
      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
    • createTagByTitle

      public org.apache.sling.testing.clients.SlingHttpResponse createTagByTitle(String tagId, String tagTitle, String locale, String tagDescr, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Adds a tag
      Parameters:
      tagId - tag ID. mandatory.
      tagTitle - title of the Tag. mandatory.
      locale - tag locale
      tagDescr - description of the tag. Set null if not used.
      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
    • deleteTag

      public org.apache.sling.testing.clients.SlingHttpResponse deleteTag(String tagPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Removes a tag.
      Parameters:
      tagPath - path to the tag to delete. E.g. /content/cq:tags/stockphotography/animals/birds/
      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
    • activateTag

      public org.apache.sling.testing.clients.SlingHttpResponse activateTag(String path, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Activates a tag.
      Parameters:
      path - path of the tag to activate
      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
    • deactivateTag

      public org.apache.sling.testing.clients.SlingHttpResponse deactivateTag(String path, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Deactivates a tag.
      Parameters:
      path - path of the tag to deactivate
      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
    • setTagProperty

      public org.apache.sling.testing.clients.SlingHttpResponse setTagProperty(Tag tag, String propName, String propValue, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Sets a single Tag property.
      Parameters:
      tag - tag to modify
      propName - name of the property to be edited
      propValue - value to be set
      expectedStatus - list of expected HTTP Status to be returned, if not set, 200 is assumed.
      Returns:
      a SlingHttpResponse wrapping the HTML response returned by Sling
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • setTagProperties

      public org.apache.sling.testing.clients.SlingHttpResponse setTagProperties(Tag tag, List<String[]> props, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Sets multiple tag properties.
      Parameters:
      tag - Tag to be edited
      props - Array of name/value string pairs to be set
      expectedStatus - list of expected HTTP Status to be returned, if not set, 200 is assumed.
      Returns:
      a SlingHttpResponse wrapping the HTML response returned by Sling
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • getRefList2

      public org.apache.sling.testing.clients.SlingHttpResponse getRefList2(Tag tag) throws org.apache.sling.testing.clients.ClientException
      Gets list of pages referring to a tag.
      Parameters:
      tag - Tag to be edited
      Returns:
      a SlingHttpResponse wrapping the HTML response returned by Sling
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • getRefList

      public org.apache.sling.testing.clients.SlingHttpResponse getRefList(Tag tag, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Gets list of pages referring to a tag.
      Parameters:
      tag - Tag to be edited
      expectedStatus - list of expected http status codes
      Returns:
      a SlingHttpResponse wrapping the HTML response returned by Sling
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • listTag

      public org.apache.sling.testing.clients.SlingHttpResponse listTag(String tagPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Gets list of pages referring to a tag path.
      Parameters:
      tagPath - Tag to be edited
      expectedStatus - list of expected http status codes
      Returns:
      a SlingHttpResponse wrapping the HTML response returned by Sling
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • getTag

      public org.apache.sling.testing.clients.SlingHttpResponse getTag(String tagPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Gets tag details.
      Parameters:
      tagPath - Path of the tag
      expectedStatus - list of expected http status codes
      Returns:
      the http response containing the json string
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • getTags

      public com.fasterxml.jackson.databind.JsonNode getTags(String nodePath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Gets list of set tags for the given node.
      Parameters:
      nodePath - Path of the node
      expectedStatus - list of expected http status codes
      Returns:
      the list of tags as a JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • listTags

      public org.apache.sling.testing.clients.SlingHttpResponse listTags(String resourcePath, String titleSuggestion, String nameSuggestion, boolean ignoreCase, boolean matchWordStart, String locale, Boolean count, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Gets list of tags for the given node.
      Parameters:
      resourcePath - node path
      titleSuggestion - title suggestion
      nameSuggestion - name suggestion
      ignoreCase - true to ignore case
      matchWordStart - whether to match word start
      locale - tags locale
      count - count
      expectedStatus - list of expected http status codes
      Returns:
      the list of tags as a JsonNode
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycle
    • setTag

      public void setTag(String page, String tagHandle, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Sets a tag on a page
      Parameters:
      page - the page that will doGet the tag
      tagHandle - The tag handle e.g. itnamespace:testid/testlevel2. NOTE: to add a tag you have to prefix it with +.
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 201 (CREATED) is assumed.
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • setTags

      public org.apache.sling.testing.clients.SlingHttpResponse setTags(String page, List<String> tags, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Sets multiple tag on a page.
      Parameters:
      page - the page that will doGet the tags
      tags - list of tags e.g. itnamespace:testid/testlevel2. NOTE: to doGet a tag you have to prefix it with +, otherwise with -.
      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
    • moveTag

      public org.apache.sling.testing.clients.SlingHttpResponse moveTag(String from, String to, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Moves a tag.
      Parameters:
      from - tag id or path to move
      to - target tag id or path
      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
    • mergeTag

      public org.apache.sling.testing.clients.SlingHttpResponse mergeTag(String path, String destPath, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Merge a tag.
      Parameters:
      path - tag id or path to merge
      destPath - target tag id or path
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 20O (OK) is assumed.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • searchTags

      public org.apache.sling.testing.clients.SlingHttpResponse searchTags(Boolean count, String locale, String query, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • setTagGarbageCollectorCronExpression

      public org.apache.sling.testing.clients.SlingHttpResponse setTagGarbageCollectorCronExpression(String cronExpression, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • getTagGarbageCollectorConfig

      public com.fasterxml.jackson.databind.JsonNode getTagGarbageCollectorConfig(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • runGc

      public org.apache.sling.testing.clients.SlingHttpResponse runGc(int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException