Class Start
java.lang.Object
com.adobe.cq.testing.client.components.AbstractComponent
com.adobe.cq.testing.client.components.foundation.form.Start
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Charset
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class com.adobe.cq.testing.client.components.AbstractComponent
changeProperties, client, componentPath, DEFAULT_LOCATION, jsonNode, location, pagePath
-
Constructor Summary
ConstructorDescriptionStart
(ComponentClient client, String pagePath, String location, String nameHint) The constructor stores all the component path information like parentPage, name etc. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.sling.testing.clients.SlingHttpResponse
We override the default create call, so we can capture the reference to the end component.org.apache.http.HttpEntity
Create a MultiPartEntity out of the all the values of the Form components which are between this Start component and its End component in the page paragraph list.org.apache.sling.testing.clients.util.FormEntityBuilder
getCreateFormEntity
(String order) Returns the FormEntityBuilder used for the create request inAbstractComponent.create(String,int...)
.Get the action property value (which is the action store content path) from this start component.Returns the end form component that belongs to this start component.Convenience method that returns the form idgetFormValue
(String componentName) returns the string value set for this form elementThe resource type for the component, e.g.void
setActionType
(String actionTypeHandle) Defines what type of action should be executed upon form submission.void
setClientValidation
(boolean validate) Defines if the form should get validated client side before submissionvoid
setClientValidationResourceType
(String resourceType) Defines a form validation resource type if you want to validate the entire form (instead of individual fields).void
setFormActionStore
(String contentPath) Sets action type to 'Store Content', and sets the 'Action' path where the data will get stored.void
Sets the form idvoid
setFormValueToSubmit
(String componentName, Object value) The value we want to submit for a form field.void
setRedirect
(String pageHandle) Sets the handle for the redirect after form submit.void
setWorkflowModel
(String modelHandle) Set workflow model that should be started on form submission.void
submit()
this method will 'emulate' the submit of this form by rebuilding the multipart/form-data request, collecting all the values from the form fields found between the start and end componentorg.apache.sling.testing.clients.SlingHttpResponse
submit2()
this method will 'emulate' the submit of this form by rebuilding the multipart/form-data request, collecting all the values from the form fields found between the start and end componentMethods inherited from class com.adobe.cq.testing.client.components.AbstractComponent
getClient, getComponentNode, getComponentPath, getFirstChild, getLocation, getName, getNext, getNextNodePath, getPagePath, getParentPath, getPrevious, getPreviousNodePath, getProperty, getPropertyAsString, getPropertyAsStringArray, reorder, save, setProperty, setProperty
-
Field Details
-
RESOURCE_TYPE
- See Also:
-
PROP_REDIRECT
- See Also:
-
PROP_WORKFLOW
- See Also:
-
PROP_ACTION_TYPE
- See Also:
-
PROP_FORM_ID
- See Also:
-
PROP_CLIENT_VALIDATION
- See Also:
-
PROP_VALIDATION_RT
- See Also:
-
OPT_ACTION_TYPE_STORE
- See Also:
-
PROP_ACTION_STORE_CONTENT_PATH
- See Also:
-
CHARSET_UTF8
-
-
Constructor Details
-
Start
The constructor stores all the component path information like parentPage, name etc.- Parameters:
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. TheAbstractComponent.getName()
method will return the correct name after(order,int...)
has been called.
-
-
Method Details
-
getResourceType
Description copied from class:AbstractComponent
The resource type for the component, e.g. foundation/components/text. this will be set in thesling:resourceType
property of the node.- Specified by:
getResourceType
in classAbstractComponent
- Returns:
- the resource type
-
getCreateFormEntity
Description copied from class:AbstractComponent
Returns the FormEntityBuilder used for the create request inAbstractComponent.create(String,int...)
. This method can be overridden in a subclass to extend the parameters that need to sent with the creation request.- Overrides:
getCreateFormEntity
in classAbstractComponent
- Parameters:
order
- Defines where the component should be added in relation to its siblings. Possible values arefirst
,last
,before [nodeName]
,after [nodeName]
.- Returns:
- An FormEntityBuilder with
_charset_
,./sling:resourceType
and:nameHint
set.
-
create
public org.apache.sling.testing.clients.SlingHttpResponse create(String order, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException We override the default create call, so we can capture the reference to the end component. The end component is created right after the start component.- Overrides:
create
in classAbstractComponent
- Parameters:
order
- Defines where the component should be added in relation to its siblings. Possible values arefirst
,last
,before [nodeName]
,after [nodeName]
.expectedStatus
- list of expected HTTP Status to be returned, if not set, 201 is assumed.- Returns:
- Sling response
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
getFormEndComponent
Returns the end form component that belongs to this start component.- Returns:
- The end component for this start component
-
setRedirect
Sets the handle for the redirect after form submit. e.g. /content/site/thank_you- Parameters:
pageHandle
- handle to redirect page
-
setWorkflowModel
Set workflow model that should be started on form submission.- Parameters:
modelHandle
- handle of of the workflow model
-
setActionType
Defines what type of action should be executed upon form submission. actions are implemented as components so this value must be a handle to a node in the repository that has sling:resourceType set to foundation/components/form/action.- Parameters:
actionTypeHandle
- handle to the action component
-
setFormId
Sets the form id- Parameters:
formId
- name for the form id
-
getFormId
Convenience method that returns the form id- Returns:
- the form id set, otherwise null
-
setClientValidation
public void setClientValidation(boolean validate) Defines if the form should get validated client side before submission- Parameters:
validate
- set true if client validation of form should occur.
-
setClientValidationResourceType
Defines a form validation resource type if you want to validate the entire form (instead of individual fields).- Parameters:
resourceType
- the validation resource type
-
setFormActionStore
Sets action type to 'Store Content', and sets the 'Action' path where the data will get stored.- Parameters:
contentPath
- path where the data will be stored
-
getFormActionStore
public String getFormActionStore() throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionGet the action property value (which is the action store content path) from this start component.- Returns:
- the action property value
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
submit
this method will 'emulate' the submit of this form by rebuilding the multipart/form-data request, collecting all the values from the form fields found between the start and end component- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
submit2
public org.apache.sling.testing.clients.SlingHttpResponse submit2() throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionthis method will 'emulate' the submit of this form by rebuilding the multipart/form-data request, collecting all the values from the form fields found between the start and end component- Returns:
- the sling http response
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
createMultipartEntity
public org.apache.http.HttpEntity createMultipartEntity() throws org.apache.sling.testing.clients.ClientException, InterruptedExceptionCreate a MultiPartEntity out of the all the values of the Form components which are between this Start component and its End component in the page paragraph list. This MultiPartEntity is used to submit the form data to the server. Accepted as Form values are: - String for single value parameter if the parameter name is the same as the component name - String Array for multi value parameters if the parameter name is the same as the component name - File for File Uploads - Map of Strings for Form components which are sending several parameters (e.g Captcha)- Returns:
- the MultipartEntity with the Form values.
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request failsInterruptedException
- to mark this method as waiting
-
setFormValueToSubmit
The value we want to submit for a form field. The value is only submitted if the corresponding form field component still exists at time whensubmit()
gets called and is located between the form start and end component. If the the value is not set or set to null at the time of submitting then the form field is not added at all. If set to an empty String, it will submitted as such.- Parameters:
componentName
- the name of the form field component, associated with this valuevalue
- the value send upon submit of the form
-
getFormValue
public String getFormValue(String componentName) throws org.apache.sling.testing.clients.ClientException returns the string value set for this form element- Parameters:
componentName
- component name- Returns:
- the string value set
- Throws:
org.apache.sling.testing.clients.ClientException
- if the request fails
-