public abstract class AbstractComponent extends Object
| Modifier and Type | Field and Description |
|---|---|
protected HashMap<String,String[]> |
changeProperties
Stores the currently set of edited property values
|
protected ComponentClient |
client
Reference to the
FoundationClient that created
this instance |
protected String |
componentPath
The complete path to this component in the repository.
|
static String |
DEFAULT_LOCATION
Deprecated.
- use the component's
getLocation() method as this value is not applicable to all websites |
protected org.codehaus.jackson.JsonNode |
jsonNode
contains the Json Structure as it is currently saved on the server
|
protected String |
location
relative location inside the page
|
protected String |
pagePath
Path to the CQ page that contains this component
|
| Constructor and Description |
|---|
AbstractComponent(ComponentClient client,
String pagePath,
String location,
String nameHint)
The constructor stores all the component path information like parentPage, name etc.
|
| Modifier and Type | Method and Description |
|---|---|
org.apache.sling.testing.clients.SlingHttpResponse |
create(String order,
int... expectedStatus)
Creates the component on the server by sending the http request.
|
ComponentClient |
getClient()
Returns the client that created this component.
|
org.codehaus.jackson.JsonNode |
getComponentNode()
Returns the root node of the component node as a JsonNode
|
String |
getComponentPath()
The complete path to the component.
|
org.apache.sling.testing.clients.util.FormEntityBuilder |
getCreateFormEntity(String order)
Returns the FormEntityBuilder used for the create request in
create(String,int...). |
<T extends AbstractComponent> |
getFirstChild()
returns the first child node that is a component or null if not found.
|
String |
getLocation()
returns the relative path inside the page
|
String |
getName()
Returns the name of the component node.
|
<T extends AbstractComponent> |
getNext()
Returns the component wrapper instance for the following sibling or null if this component
is already the last one.
|
String |
getNextNodePath()
Returns the component path for the following sibling or null if this component is already
the last one.
|
String |
getPagePath()
returns the path to the page that contains the component
|
String |
getParentPath()
Path to the parent node of the component
|
<T extends AbstractComponent> |
getPrevious()
Returns the component wrapper instance for the previous sibling or null if this component
is already the first one.
|
String |
getPreviousNodePath()
Returns the component path for the previous sibling or null if this component is already
the last one.
|
org.codehaus.jackson.JsonNode |
getProperty(String propName)
returns a components property as JsonNode.
|
String |
getPropertyAsString(String propName)
Returns the property value as string, as it is saved at the moment on the server.
|
String[] |
getPropertyAsStringArray(String propName)
Returns the property value as string array, as it is saved at the moment on the server.
|
abstract String |
getResourceType()
The resource type for the component, e.g.
|
org.apache.sling.testing.clients.SlingHttpResponse |
reorder(String order,
int... expectedStatus)
Allows reordering of a component in relation to its siblings.
|
org.apache.sling.testing.clients.SlingHttpResponse |
save(int... expectedStatus)
Submits all editable values to the server.
|
void |
setProperty(String name,
int value)
sets a integer to be saved.
|
void |
setProperty(String name,
String... value)
sets a string or multiple string property to be saved.
|
protected HashMap<String,String[]> changeProperties
@Deprecated public static final String DEFAULT_LOCATION
getLocation() method as this value is not applicable to all websitesprotected ComponentClient client
FoundationClient that created
this instanceprotected String componentPath
protected String pagePath
protected String location
protected org.codehaus.jackson.JsonNode jsonNode
public AbstractComponent(ComponentClient client, String pagePath, String location, String nameHint)
client - The ComponentClient that will be used for sending the requests.pagePath - path to the page that will contain the component.location - relative location to the parent node inside the page that will contain the component node.nameHint - name to be used for the component node. Might get altered by the server if a naming conflict
occurs. The getName() method will return the correct name after (order,int...) has been called.public org.apache.sling.testing.clients.SlingHttpResponse create(String order, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
order - Defines where the component should be added in relation to its siblings. Possible values
are first, last, before [nodeName], after [nodeName].expectedStatus - list of expected HTTP Status to be returned, if not set, 201 is assumed.org.apache.sling.testing.clients.ClientException - if something fails during the request/response cycleInterruptedException - to mark this method as waitingpublic org.apache.sling.testing.clients.util.FormEntityBuilder getCreateFormEntity(String order)
create(String,int...). This method can be
overridden in a subclass to extend the parameters that need to sent with the creation request.order - Defines where the component should be added in relation to its siblings. Possible values
are first, last, before [nodeName], after [nodeName]._charset_,./sling:resourceType and
:nameHint set.public org.apache.sling.testing.clients.SlingHttpResponse save(int... expectedStatus)
throws org.apache.sling.testing.clients.ClientException,
InterruptedException
OK button on the edit dialog
of a component.expectedStatus - list of allowed HTTP Status to be returned. if not set, status 200 is assumedorg.apache.sling.testing.clients.ClientException - If something fails during request/response cycleInterruptedException - to mark this method as waitingpublic org.apache.sling.testing.clients.SlingHttpResponse reorder(String order, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
order - Defines where the component should be added in relation to its siblings. Possible values
are first, last, before [nodeName], after [nodeName].expectedStatus - list of allowed HTTP Status to be returned. if not set, status 200 is assumedorg.apache.sling.testing.clients.ClientException - if posting the reorder failsInterruptedException - to mark this method as waitingpublic void setProperty(String name, String... value)
name - name of the property to set e.g. ./text.value - the value(s) to be set.public void setProperty(String name, int value)
name - name of the property to set e.g. ./width.value - the value(s) to be set.public String getPropertyAsString(String propName)
propName - name of the propertynull if no such property has been saved yet.public String[] getPropertyAsStringArray(String propName)
propName - name of the propertynull if no such property has been saved yet.public org.codehaus.jackson.JsonNode getProperty(String propName)
propName - the property to getpublic org.codehaus.jackson.JsonNode getComponentNode()
throws org.apache.sling.testing.clients.ClientException,
InterruptedException
org.apache.sling.testing.clients.ClientException - if something fails during requestInterruptedException - to mark this method as waitingpublic String getName()
public String getParentPath()
public String getComponentPath()
public String getPagePath()
public String getLocation()
public abstract String getResourceType()
sling:resourceType property of the node.public ComponentClient getClient()
public <T extends AbstractComponent> T getNext() throws org.apache.sling.testing.clients.ClientException, InterruptedException
ComponentClient.registerComponent(String, Class))T - component typeorg.apache.sling.testing.clients.ClientException - if something goes wrong during request/response of json.InterruptedException - to mark this method as waitingpublic String getNextNodePath() throws org.apache.sling.testing.clients.ClientException, InterruptedException
org.apache.sling.testing.clients.ClientException - if something goes wrong during request/response of json.InterruptedException - to mark this method as waitingpublic <T extends AbstractComponent> T getFirstChild() throws org.apache.sling.testing.clients.ClientException, InterruptedException
T - a subclass of AbstractComponentorg.apache.sling.testing.clients.ClientException - if requesting json fails.InterruptedException - to mark this method as waitingpublic <T extends AbstractComponent> T getPrevious() throws org.apache.sling.testing.clients.ClientException, InterruptedException
ComponentClient.registerComponent(String, Class))T - component typeorg.apache.sling.testing.clients.ClientException - if something goes wrong during request/response of jsonInterruptedException - to mark this method as waitingpublic String getPreviousNodePath() throws org.apache.sling.testing.clients.ClientException, InterruptedException
org.apache.sling.testing.clients.ClientException - if something goes wrong during request/response of json.InterruptedException - to mark this method as waitingCopyright © 2021. All rights reserved.