Package com.adobe.cq.testing.client
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
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
It extends from
CQClient
which in turn provides a core set of commonly used website and
page functionality.-
Nested Class Summary
Nested classes/interfaces inherited from class com.adobe.cq.testing.client.CQClient
CQClient.Builder, CQClient.InternalBuilder<T extends CQClient>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static String
static String
static final String
Fields inherited from class com.adobe.cq.testing.client.CQClient
LOG, STATISTICS_ROOT, wcmCommands
Fields inherited from class org.apache.sling.testing.clients.SlingClient
CLIENT_CONNECTION_TIMEOUT_PROP, DEFAULT_NODE_TYPE, SUDO_COOKIE_NAME
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.apache.sling.testing.clients.SlingHttpResponse
activateTag
(String path, int... expectedStatus) Activates a tag.org.apache.sling.testing.clients.SlingHttpResponse
addTagCloudComponent
(String pageHandle, int... expectedStatus) Adds a TagCloud Component to a page.org.apache.sling.testing.clients.SlingHttpResponse
canCreateTag
(String tagId, int... expectedStatus) Checks if user can create a specific Tagorg.apache.sling.testing.clients.SlingHttpResponse
canCreateTagByTitle
(String tagId, String locale, int... expectedStatus) Checks if user can create a specific Tag based on titleorg.apache.sling.testing.clients.SlingHttpResponse
createTag
(String tagTitle, String tagId, String tagDescr, String parentTagId, int... expectedStatus) Adds a tagorg.apache.sling.testing.clients.SlingHttpResponse
createTagByTitle
(String tagId, String tagTitle, String locale, String tagDescr, int... expectedStatus) Adds a tagorg.apache.sling.testing.clients.SlingHttpResponse
deactivateTag
(String path, int... expectedStatus) Deactivates a tag.org.apache.sling.testing.clients.SlingHttpResponse
Removes a tag.org.apache.sling.testing.clients.SlingHttpResponse
editTagCloudComponent
(String componentPath, boolean showAsLink, String path, String display, int... expectedStatus) Edits the TagCloud component.org.apache.sling.testing.clients.SlingHttpResponse
getRefList
(Tag tag, int... expectedStatus) Gets list of pages referring to a tag.org.apache.sling.testing.clients.SlingHttpResponse
getRefList2
(Tag tag) Gets list of pages referring to a tag.org.apache.sling.testing.clients.SlingHttpResponse
Gets tag details.com.fasterxml.jackson.databind.JsonNode
getTagGarbageCollectorConfig
(int... expectedStatus) com.fasterxml.jackson.databind.JsonNode
Gets list of set tags for the given node.org.apache.sling.testing.clients.SlingHttpResponse
Gets list of pages referring to a tag path.org.apache.sling.testing.clients.SlingHttpResponse
listTags
(String resourcePath, String titleSuggestion, String nameSuggestion, boolean ignoreCase, boolean matchWordStart, String locale, Boolean count, int... expectedStatus) Gets list of tags for the given node.org.apache.sling.testing.clients.SlingHttpResponse
Merge a tag.org.apache.sling.testing.clients.SlingHttpResponse
Moves a tag.org.apache.sling.testing.clients.SlingHttpResponse
runGc
(int... expectedStatus) org.apache.sling.testing.clients.SlingHttpResponse
searchTags
(Boolean count, String locale, String query, int... expectedStatus) void
Sets a tag on a pageorg.apache.sling.testing.clients.SlingHttpResponse
setTagGarbageCollectorCronExpression
(String cronExpression, int... expectedStatus) org.apache.sling.testing.clients.SlingHttpResponse
setTagProperties
(Tag tag, List<String[]> props, int... expectedStatus) Sets multiple tag properties.org.apache.sling.testing.clients.SlingHttpResponse
setTagProperty
(Tag tag, String propName, String propValue, int... expectedStatus) Sets a single Tag property.org.apache.sling.testing.clients.SlingHttpResponse
Sets multiple tag on a page.Methods inherited from class com.adobe.cq.testing.client.CQClient
copyLanguages, copyPage, createPage, createPageWithRetry, createVersion, deletePage, deletePageWithRetry, getAuthorSitesPage, lockPage, movePage, movePage, pageExists, pageExistsWithRetry, pageExistsWithRetry, resetPageStatistics, restoreTree, restoreVersion, rolloutPage, searchAndReplaceInPages, searchInPages, setPageProperties, setPageProperty, setPagePropertyImage, unlockPage, uploadFileCQStyle
Methods inherited from class org.apache.sling.testing.clients.SlingClient
createFolder, createNode, createNodeRecursive, deletePath, doGetJson, endImpersonation, exists, getJsonNode, getJsonNode, getNodeNameFromPath, getParentPath, getUser, getUUId, getUUID, impersonate, importContent, importContent, importJson, move, setPropertiesString, setPropertyString, setPropertyStringArray, upload, waitExists, waitUntilExists
Methods inherited from class org.apache.sling.testing.clients.AbstractSlingClient
adaptTo, addValue, close, doDelete, doGet, doGet, doGet, doHead, doPatch, doPost, doPost, doPut, doRawRequest, doRequest, doStreamGet, doStreamPost, doStreamRequest, execute, execute, execute, execute, execute, execute, execute, execute, getClientId, getConnectionManager, getCookieStore, getCredentialsProvider, getParams, getPassword, getPath, getPath, getUrl, getUrl, getUrl, getValue, getValues, hasValue
-
Field Details
-
TAG_COMMAND_PATH
- See Also:
-
TAG_RESOURCE_PATH
- See Also:
-
TAG_GARBAGE_COLLECTOR_DEFAULT_CRON_EXPRESSION
-
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 addedexpectedStatus
- 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 pathshowAsLink
- 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 localetagDescr
- 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 activateexpectedStatus
- 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 deactivateexpectedStatus
- 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 modifypropName
- name of the property to be editedpropValue
- value to be setexpectedStatus
- 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 editedprops
- Array of name/value string pairs to be setexpectedStatus
- 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 editedexpectedStatus
- 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 editedexpectedStatus
- 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 tagexpectedStatus
- 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 nodeexpectedStatus
- 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 pathtitleSuggestion
- title suggestionnameSuggestion
- name suggestionignoreCase
- true to ignore casematchWordStart
- whether to match word startlocale
- tags localecount
- countexpectedStatus
- 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 tagtagHandle
- 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 tagstags
- 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 moveto
- target tag id or pathexpectedStatus
- 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 mergedestPath
- target tag id or pathexpectedStatus
- 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
-