Class CommonG
- java.lang.Object
-
- com.privalia.qa.specs.CommonG
-
public class CommonG extends Object
Class with common functions used by all the step definition classes
-
-
Constructor Summary
Constructors Constructor Description CommonG()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptSeleniumAlert()
Accepts any existing alert message in the current selenium contextString
captureEvidence(org.openqa.selenium.WebDriver driver, String type)
Capture a snapshot or an evidence in the driverString
captureEvidence(org.openqa.selenium.WebDriver driver, String type, String suffix)
Capture a snapshot or an evidence in the drivervoid
dismissSeleniumAlert()
Dismiss any existing alert message in the current selenium contextvoid
evaluateJSONElementOperation(String value, String condition, String result, String jsonPath)
Evaluate an expression.void
generateRestRequest(String requestType, String endPoint)
Generates a request to a REST endpointString
getBrowserName()
Get the browser name.CassandraUtils
getCassandraClient()
Get the cassandra utils.com.datastax.driver.core.ResultSet
getCassandraResults()
int
getCommandExitStatus()
String
getCommandResult()
List<org.openqa.selenium.Cookie>
getCookies()
List<Map<String,String>>
getCSVResults()
org.openqa.selenium.WebDriver
getDriver()
Get the remoteWebDriver.ElasticSearchUtils
getElasticSearchClient()
Get the elasticSearch utils.List<org.json.JSONObject>
getElasticsearchResults()
List<Exception>
getExceptions()
Get the exception list.FileParserUtils
getFileParserUtil()
Get the File Parser classString
getJSONPathString(String jsonString, String expr, String position)
Parse jsonpath expression from a given string.KafkaUtils
getKafkaUtils()
Get the Kafka utils.Map<String,String>
getLastFileParseRecord()
Returns the last selected recordList<Map<String,String>>
getLastFileParseResult()
Returns the records resulted from the last operation when decoding/parsing filesString
getLastSoapResponse()
Returns the las response from a remote method execution in the webservice as an XML Stringorg.apache.logging.log4j.Logger
getLogger()
Get the common logger.MongoDBUtils
getMongoDBClient()
Get the MongoDB utils.com.mongodb.DBCursor
getMongoResults()
String
getParentWindow()
Returns the parentWindowList<List<String>>
getPreviousSqlResult()
Get the SQL result from the last stepPreviousWebElements
getPreviousWebElements()
Returns the previous webElementRemoteSSHConnection
getRemoteSSHConnection()
Get the common remote connection.String
getRestHost()
Get the common REST host.String
getRestPort()
Get the common REST port.String
getRestProtocol()
io.restassured.specification.RequestSpecification
getRestRequest()
Returns the Rest Request object (restassured)io.restassured.response.Response
getRestResponse()
Get the previos Rest response (restassured)String
getResultsType()
org.openqa.selenium.Alert
getSeleniumAlert()
Set<org.openqa.selenium.Cookie>
getSeleniumCookies()
SoapServiceUtils
getSoapServiceClient()
Get the SOAP Services utils.SqlUtils
getSqlClient()
Get the SQL utils.org.assertj.core.api.Condition<org.openqa.selenium.WebElement>
getTextFieldCondition()
Get the textFieldCondition list.String
getVariable(String variable)
Returns the value of the given placeholder as used in the gherkin stepString
getWebHost()
Get the common WEB host.String
getWebPort()
Get the common WEB port.ZookeeperSecUtils
getZookeeperSecClient()
Get the Zookeeper Sec utils.List<org.openqa.selenium.WebElement>
locateElement(String method, String element, Integer expectedCount)
Looks for webelements inside a selenium context.List<org.openqa.selenium.WebElement>
locateElementWithPooling(int poolingInterval, int poolMaxTime, String method, String element, Integer expectedCount, String type)
Similar tolocateElement(String, String, Integer)
.static Pattern
matchesOrContains(String expectedMessage)
Checks if a given string matches a regular expression or contains a stringString
modifyData(String data, String type, io.cucumber.datatable.DataTable modifications)
Returns the information modifiedString
removeJSONPathElement(String jsonString, String expr)
Remove a subelement in a JsonPathString
replaceJSONPathElement(String jsonString, String key, String value)
The function searches over the array by certain field value, and replaces occurences with the parameter provided.void
resultsMustBeCassandra(io.cucumber.datatable.DataTable expectedResults)
Checks the different results of a previous query to Cassandra databasevoid
resultsMustBeCSV(io.cucumber.datatable.DataTable expectedResults)
Checks the different results of a previous query to CSV filevoid
resultsMustBeElasticsearch(io.cucumber.datatable.DataTable expectedResults)
Checks the different results of a previous query to Elasticsearch databasevoid
resultsMustBeMongo(io.cucumber.datatable.DataTable expectedResults)
Checks the different results of a previous query to Mongo databaseString
retrieveData(String baseData, String type)
Returns the information contained in file passed as parameter.String
retrieveData(String baseData, String type, String charset)
Returns the information contained in file passed as parametervoid
runCommandAndGetResult(String command)
void
runCommandLoggerAndEnvVar(int exitStatus, String envVar, Boolean local)
void
runLocalCommand(String command)
Runs a command locallyvoid
setBrowserName(String browserName)
Set the browser name.void
setCassandraResults(com.datastax.driver.core.ResultSet results)
void
setCommandExitStatus(int commandExitStatus)
void
setCommandResult(String commandResult)
void
setCookies(List<org.openqa.selenium.Cookie> cookies)
void
setCSVResults(List<Map<String,String>> results)
void
setDriver(org.openqa.selenium.WebDriver driver)
Set the remoteDriver.void
setElasticsearchResults(List<org.json.JSONObject> results)
void
setLastFileParseRecord(Map<String,String> lastFileParseRecord)
Sets the record for the last operationvoid
setLastFileParseResult(List<Map<String,String>> lastFileParseResult)
Stores the result of an operation when decoding/parsing filesvoid
setLastSoapResponse(String lastSoapResponse)
Sets the response of the execution of a remote method in a webservice as an XML Stringvoid
setMongoResults(com.mongodb.DBCursor results)
void
setParentWindow(String windowHandle)
Sets the parentWindowvoid
setPreviousElement(String element, String value)
Saves the value in the attribute in class extending CommonG.void
setPreviousSqlResult(List<List<String>> previousSqlResult)
Sets the result of the SQL sentencevoid
setPreviousWebElements(PreviousWebElements previousWebElements)
Set the previous webElementvoid
setRemoteSSHConnection(RemoteSSHConnection remoteSSHConnection)
Set the remote connection.void
setRestHost(String restHost)
Set the REST host.void
setRestPort(String restPort)
Set the REST port.void
setRestProtocol(String restProtocol)
Set the REST host.void
setRestRequest(io.restassured.specification.RequestSpecification restRequest)
Sets the Rest request object (restassured)void
setRestResponse(io.restassured.response.Response restResponse)
Sets the Rest response (restassured)void
setResultsType(String resultsType)
void
setSeleniumAlert(org.openqa.selenium.Alert seleniumAlert)
void
setSeleniumCookies(Set<org.openqa.selenium.Cookie> cookies)
void
setWebHost(String webHost)
Set the WEB host.void
setWebPort(String webPort)
Set the WEB port.String
updateMarathonJson(String json)
org.openqa.selenium.Alert
waitAlertWithPooling(int poolingInterval, int poolMaxTime)
Similar tolocateElementWithPooling(int, int, String, String, Integer, String)
, looks for an alert message inside a selenium context.
-
-
-
Method Detail
-
getSeleniumAlert
public org.openqa.selenium.Alert getSeleniumAlert()
-
setSeleniumAlert
public void setSeleniumAlert(org.openqa.selenium.Alert seleniumAlert)
-
getRestProtocol
public String getRestProtocol()
-
setRestProtocol
public void setRestProtocol(String restProtocol)
Set the REST host.- Parameters:
restProtocol
- api protocol "http or https"
-
getCookies
public List<org.openqa.selenium.Cookie> getCookies()
-
setCookies
public void setCookies(List<org.openqa.selenium.Cookie> cookies)
-
getSeleniumCookies
public Set<org.openqa.selenium.Cookie> getSeleniumCookies()
-
setSeleniumCookies
public void setSeleniumCookies(Set<org.openqa.selenium.Cookie> cookies)
-
matchesOrContains
public static Pattern matchesOrContains(String expectedMessage)
Checks if a given string matches a regular expression or contains a string- Parameters:
expectedMessage
- message used for comparing- Returns:
- boolean
-
getLastFileParseRecord
public Map<String,String> getLastFileParseRecord()
Returns the last selected record- Returns:
- record in the set
-
setLastFileParseRecord
public void setLastFileParseRecord(Map<String,String> lastFileParseRecord)
Sets the record for the last operation- Parameters:
lastFileParseRecord
- record in the set
-
getLastSoapResponse
public String getLastSoapResponse()
Returns the las response from a remote method execution in the webservice as an XML String- Returns:
- XML String
-
setLastSoapResponse
public void setLastSoapResponse(String lastSoapResponse)
Sets the response of the execution of a remote method in a webservice as an XML String- Parameters:
lastSoapResponse
- SOAP response of last operation
-
getLastFileParseResult
public List<Map<String,String>> getLastFileParseResult()
Returns the records resulted from the last operation when decoding/parsing files- Returns:
- records from last operation
-
setLastFileParseResult
public void setLastFileParseResult(List<Map<String,String>> lastFileParseResult)
Stores the result of an operation when decoding/parsing files- Parameters:
lastFileParseResult
- records as result of last operation
-
getRestResponse
public io.restassured.response.Response getRestResponse()
Get the previos Rest response (restassured)- Returns:
- Rest response
-
setRestResponse
public void setRestResponse(io.restassured.response.Response restResponse)
Sets the Rest response (restassured)- Parameters:
restResponse
- Rest response
-
getRestRequest
public io.restassured.specification.RequestSpecification getRestRequest()
Returns the Rest Request object (restassured)- Returns:
- Rest Request object (restassured)
-
setRestRequest
public void setRestRequest(io.restassured.specification.RequestSpecification restRequest)
Sets the Rest request object (restassured)- Parameters:
restRequest
- Rest Request object (restassured)
-
getPreviousSqlResult
public List<List<String>> getPreviousSqlResult()
Get the SQL result from the last step- Returns:
- SQL result
-
setPreviousSqlResult
public void setPreviousSqlResult(List<List<String>> previousSqlResult)
Sets the result of the SQL sentence- Parameters:
previousSqlResult
- SQL result
-
getRemoteSSHConnection
public RemoteSSHConnection getRemoteSSHConnection()
Get the common remote connection.- Returns:
- RemoteConnection
-
setRemoteSSHConnection
public void setRemoteSSHConnection(RemoteSSHConnection remoteSSHConnection)
Set the remote connection.- Parameters:
remoteSSHConnection
- remoteSSHConnection connection object
-
getRestHost
public String getRestHost()
Get the common REST host.- Returns:
- REST host
-
setRestHost
public void setRestHost(String restHost)
Set the REST host.- Parameters:
restHost
- api host
-
getRestPort
public String getRestPort()
Get the common REST port.- Returns:
- String
-
setRestPort
public void setRestPort(String restPort)
Set the REST port.- Parameters:
restPort
- api port
-
getWebHost
public String getWebHost()
Get the common WEB host.- Returns:
- String
-
setWebHost
public void setWebHost(String webHost)
Set the WEB host.- Parameters:
webHost
- host where app is running
-
getWebPort
public String getWebPort()
Get the common WEB port.- Returns:
- String
-
setWebPort
public void setWebPort(String webPort)
Set the WEB port.- Parameters:
webPort
- port where app is running
-
getLogger
public org.apache.logging.log4j.Logger getLogger()
Get the common logger.- Returns:
- Logger
-
getExceptions
public List<Exception> getExceptions()
Get the exception list.- Returns:
- List(Exception)
-
getTextFieldCondition
public org.assertj.core.api.Condition<org.openqa.selenium.WebElement> getTextFieldCondition()
Get the textFieldCondition list.- Returns:
- List(Exception)
-
getCassandraClient
public CassandraUtils getCassandraClient()
Get the cassandra utils.- Returns:
- CassandraUtils
-
getElasticSearchClient
public ElasticSearchUtils getElasticSearchClient()
Get the elasticSearch utils.- Returns:
- ElasticSearchUtils
-
getKafkaUtils
public KafkaUtils getKafkaUtils()
Get the Kafka utils.- Returns:
- KafkaUtils
-
getMongoDBClient
public MongoDBUtils getMongoDBClient()
Get the MongoDB utils.- Returns:
- MongoDBUtils
-
getSqlClient
public SqlUtils getSqlClient()
Get the SQL utils.- Returns:
- SqlUtils
-
getSoapServiceClient
public SoapServiceUtils getSoapServiceClient()
Get the SOAP Services utils.- Returns:
- SoapServiceUtils
-
getFileParserUtil
public FileParserUtils getFileParserUtil()
Get the File Parser class- Returns:
- FileParserUtils
-
getZookeeperSecClient
public ZookeeperSecUtils getZookeeperSecClient()
Get the Zookeeper Sec utils.- Returns:
- ZookeperSecUtils
-
getDriver
public org.openqa.selenium.WebDriver getDriver()
Get the remoteWebDriver.- Returns:
- RemoteWebDriver
-
setDriver
public void setDriver(org.openqa.selenium.WebDriver driver)
Set the remoteDriver.- Parameters:
driver
- driver to be used for testing
-
getBrowserName
public String getBrowserName()
Get the browser name.- Returns:
- String
-
setBrowserName
public void setBrowserName(String browserName)
Set the browser name.- Parameters:
browserName
- browser to be used for testing
-
locateElement
public List<org.openqa.selenium.WebElement> locateElement(String method, String element, Integer expectedCount)
Looks for webelements inside a selenium context. This search will be made by id, name and xpath expression matching anlocator
value- Parameters:
method
- class of element to be searchedelement
- webElement searched in selenium contextexpectedCount
- integer. Expected number of elements.- Returns:
- List(WebElement)
-
locateElementWithPooling
public List<org.openqa.selenium.WebElement> locateElementWithPooling(int poolingInterval, int poolMaxTime, String method, String element, Integer expectedCount, String type)
Similar tolocateElement(String, String, Integer)
. Looks for webelements inside a selenium context but with a wait condition. Instead of returning immediately a fail if the element is not found, the method waits a maximum time (poolMaxTime) in which the condition is checked in intervals (poolingInterval). The method also verify if the required elements are of the type specified.- Parameters:
poolingInterval
- Time between consecutive condition evaluationspoolMaxTime
- Maximum time to wait for the condition to be truemethod
- class of element to be searchedelement
- webElement searched in selenium contextexpectedCount
- integer. Expected number of elements.type
- The expected style of the element: visible, clickable, present, hidden- Returns:
- List(WebElement)
-
waitAlertWithPooling
public org.openqa.selenium.Alert waitAlertWithPooling(int poolingInterval, int poolMaxTime)
Similar tolocateElementWithPooling(int, int, String, String, Integer, String)
, looks for an alert message inside a selenium context. The method waits a maximum time (poolMaxTime) in which the condition is checked in intervals (poolingInterval).- Parameters:
poolingInterval
- Time between consecutive condition evaluationspoolMaxTime
- Maximum time to wait for the condition to be true- Returns:
- A selenium Alert object
-
dismissSeleniumAlert
public void dismissSeleniumAlert()
Dismiss any existing alert message in the current selenium context
-
acceptSeleniumAlert
public void acceptSeleniumAlert()
Accepts any existing alert message in the current selenium context
-
captureEvidence
public String captureEvidence(org.openqa.selenium.WebDriver driver, String type)
Capture a snapshot or an evidence in the driver- Parameters:
driver
- driver used for testingtype
- type- Returns:
- String
-
captureEvidence
public String captureEvidence(org.openqa.selenium.WebDriver driver, String type, String suffix)
Capture a snapshot or an evidence in the driver- Parameters:
driver
- driver used for testingtype
- typesuffix
- suffix- Returns:
- String
-
getPreviousWebElements
public PreviousWebElements getPreviousWebElements()
Returns the previous webElement- Returns:
- List(WebElement)
-
setPreviousWebElements
public void setPreviousWebElements(PreviousWebElements previousWebElements)
Set the previous webElement- Parameters:
previousWebElements
- webElement
-
getParentWindow
public String getParentWindow()
Returns the parentWindow- Returns:
- String
-
setParentWindow
public void setParentWindow(String windowHandle)
Sets the parentWindow- Parameters:
windowHandle
- windowHandle as string
-
retrieveData
public String retrieveData(String baseData, String type) throws NonReplaceableException, org.apache.commons.configuration2.ex.ConfigurationException, FileNotFoundException, URISyntaxException
Returns the information contained in file passed as parameter. the file is read with UTF-8 charset by default- Parameters:
baseData
- path to file to be readtype
- type of information, it can be: json|string- Returns:
- String string
- Throws:
NonReplaceableException
- the non replaceable exceptionorg.apache.commons.configuration2.ex.ConfigurationException
- the configuration exceptionFileNotFoundException
- the file not found exceptionURISyntaxException
- the uri syntax exception
-
retrieveData
public String retrieveData(String baseData, String type, String charset) throws NonReplaceableException
Returns the information contained in file passed as parameter- Parameters:
baseData
- path to file to be readtype
- type of information, it can be: json|stringcharset
- charset to use when reading the file- Returns:
- String string
- Throws:
NonReplaceableException
- the non replaceable exception
-
modifyData
public String modifyData(String data, String type, io.cucumber.datatable.DataTable modifications) throws Exception
Returns the information modified- Parameters:
data
- string containing the informationtype
- type of information, it can be: json|stringmodifications
- modifications to apply with a format: WHERE,ACTION,VALUEDELETE: Delete the key in json or string in current value in case of DELETE action modifications is |key1|DELETE|N/A| and with json {"key1":"value1","key2":{"key3":null}} returns {"key2":{"key3":null}} Example 2: {"key1":"val1", "key2":"val2"} -> | key1 | DELETE | N/A | -> {"key2":"val2"} "mystring" -> | str | DELETE | N/A | -> "mying"
ADD: Add new key to json or append string to current value. in case of ADD action is |N/A|ADD|&config=config|, and with data username=username&password=password returns username=username&password=password&config=config Example 2: {"key1":"val1", "key2":"val2"} -> | key3 | ADD | val3 | -> {"key1":"val1", "key2":"val2", "key3":"val3"} "mystring" -> | N/A | ADD | new | -> "mystringnew"
UPDATE: Update value in key or modify part of string. in case of UPDATE action is |username=username|UPDATE|username=NEWusername|, and with data username=username&password=password returns username=NEWusername&password=password Example 2: {"key1":"val1", "key2":"val2"} -> | key1 | UPDATE | newval1 | -> {"key1":"newval1", "key2":"val2"} "mystring" -> | str | UPDATE | mod | -> "mymoding"
PREPEND: Prepend value to key value or to string in case of PREPEND action is |username=username|PREPEND|key1=value1&|, and with data username=username&password=password returns key1=value1&username=username&password=password Example 2: {"key1":"val1", "key2":"val2"} -> | key1 | PREPEND | new | -> {"key1":"newval1", "key2":"val2"} "mystring" -> | N/A | PREPEND | new | -> "newmystring"
REPLACE: Update value in key or modify part of string. in case of REPLACE action is |key2.key3|REPLACE|lu->REPLACE| and with json {"key1":"value1","key2":{"key3":"value3"}} returns {"key1":"value1","key2":{"key3":"vaREPLACEe3"}} the format is (WHERE, ACTION, CHANGE FROM -> TO). REPLACE replaces a string or its part per other string
if modifications has fourth argument, the replacement is effected per special json object the format is: (WHERE, ACTION, CHANGE_TO, JSON_TYPE), WHERE is the key, ACTION is REPLACE, CHANGE_TO is the new value of the key, JSON_TYPE is the type of jason object, there are 5 special cases of json object replacements: array|object|number|boolean|null
example1: |key2.key3|REPLACE|5|number| with json {"key1":"value1","key2":{"key3":"value3"}} returns {"key1":"value1","key2":{"key3":5}} in this case it replaces value of key3 per jason number
example2: |key2.key3|REPLACE|{}|object| with json {"key1":"value1","key2":{"key3":"value3"}} returns {"key1":"value1","key2":{"key3":{}}} in this case it replaces per empty json object
APPEND: Append value to key value or to string {"key1":"val1", "key2":"val2"} -> | key1 | APPEND | new | -> {"key1":"val1new", "key2":"val2"} "mystring" -> | N/A | APPEND | new | -> "mystringnew"
- Returns:
- String
- Throws:
Exception
- Exception
-
generateRestRequest
public void generateRestRequest(String requestType, String endPoint)
Generates a request to a REST endpoint- Parameters:
requestType
- Request type (GET, POST, PUT, DELETE, PATCH)endPoint
- Final endpoint (i.e /user/1)
-
setPreviousElement
public void setPreviousElement(String element, String value) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException
Saves the value in the attribute in class extending CommonG.- Parameters:
element
- attribute in class where to store the valuevalue
- value to be stored- Throws:
NoSuchFieldException
- exceptionSecurityException
- exceptionIllegalArgumentException
- exceptionIllegalAccessException
- exceptionInstantiationException
- exceptionClassNotFoundException
- exceptionNoSuchMethodException
- exceptionInvocationTargetException
- exception
-
getCassandraResults
public com.datastax.driver.core.ResultSet getCassandraResults()
-
setCassandraResults
public void setCassandraResults(com.datastax.driver.core.ResultSet results)
-
getMongoResults
public com.mongodb.DBCursor getMongoResults()
-
setMongoResults
public void setMongoResults(com.mongodb.DBCursor results)
-
getElasticsearchResults
public List<org.json.JSONObject> getElasticsearchResults()
-
setElasticsearchResults
public void setElasticsearchResults(List<org.json.JSONObject> results)
-
getResultsType
public String getResultsType()
-
setResultsType
public void setResultsType(String resultsType)
-
resultsMustBeCSV
public void resultsMustBeCSV(io.cucumber.datatable.DataTable expectedResults) throws Exception
Checks the different results of a previous query to CSV file- Parameters:
expectedResults
- A DataTable Object with all data needed for check the results. The DataTable must contains at least 2 columns: a) A field column from the result b) Occurrences column (Integer type)Example: |latitude| longitude|place |occurrences| |12.5 |12.7 |Valencia |1 | |2.5 | 2.6 |Madrid |0 | |12.5 |13.7 |Sevilla |1 | IMPORTANT: All columns must exist
- Throws:
Exception
- exception
-
resultsMustBeCassandra
public void resultsMustBeCassandra(io.cucumber.datatable.DataTable expectedResults) throws Exception
Checks the different results of a previous query to Cassandra database- Parameters:
expectedResults
- A DataTable Object with all data needed for check the results. The DataTable must contains at least 2 columns: a) A field column from the result b) Occurrences column (Integer type)Example: |latitude| longitude|place |occurrences| |12.5 |12.7 |Valencia |1 | |2.5 | 2.6 |Madrid |0 | |12.5 |13.7 |Sevilla |1 | IMPORTANT: All columns must exist
- Throws:
Exception
- exception
-
resultsMustBeMongo
public void resultsMustBeMongo(io.cucumber.datatable.DataTable expectedResults) throws Exception
Checks the different results of a previous query to Mongo database- Parameters:
expectedResults
- A DataTable Object with all data needed for check the results. The DataTable must contains at least 2 columns: a) A field column from the result b) Occurrences column (Integer type)Example: |latitude| longitude|place |occurrences| |12.5 |12.7 |Valencia |1 | |2.5 | 2.6 |Madrid |0 | |12.5 |13.7 |Sevilla |1 | IMPORTANT: All columns must exist
- Throws:
Exception
- exception
-
resultsMustBeElasticsearch
public void resultsMustBeElasticsearch(io.cucumber.datatable.DataTable expectedResults) throws Exception
Checks the different results of a previous query to Elasticsearch database- Parameters:
expectedResults
- A DataTable Object with all data needed for check the results. The DataTable must contains at least 2 columns: a) A field column from the result b) Occurrences column (Integer type)Example: |latitude| longitude|place |occurrences| |12.5 |12.7 |Valencia |1 | |2.5 | 2.6 |Madrid |0 | |12.5 |13.7 |Sevilla |1 | IMPORTANT: All columns must exist
- Throws:
Exception
- exception
-
runLocalCommand
public void runLocalCommand(String command) throws Exception
Runs a command locally- Parameters:
command
- Command used to be run locally- Throws:
Exception
- Exception
-
getCommandExitStatus
public int getCommandExitStatus()
-
setCommandExitStatus
public void setCommandExitStatus(int commandExitStatus)
-
getCommandResult
public String getCommandResult()
-
setCommandResult
public void setCommandResult(String commandResult)
-
getJSONPathString
public String getJSONPathString(String jsonString, String expr, String position)
Parse jsonpath expression from a given string.If the string is json we can obtain its keys using ~ symbol.
If position is not null and the result of jsonpath expression is an array, then this function will return the element at the given position at the array.
If position is null, it will return the result of the jsonpath evaluation as string.
- Parameters:
jsonString
- string to be parsedexpr
- jsonpath expressionposition
- position from a search result- Returns:
- the resulting element as string
-
removeJSONPathElement
public String removeJSONPathElement(String jsonString, String expr)
Remove a subelement in a JsonPath- Parameters:
jsonString
- String of the jsonexpr
- regex to be removed- Returns:
- new json
-
replaceJSONPathElement
public String replaceJSONPathElement(String jsonString, String key, String value)
The function searches over the array by certain field value, and replaces occurences with the parameter provided.- Parameters:
jsonString
- Original json objectkey
- Key to searchvalue
- Value to replace key with- Returns:
- new json
-
evaluateJSONElementOperation
public void evaluateJSONElementOperation(String value, String condition, String result, String jsonPath)
Evaluate an expression.Object o could be a string or a list.
- Parameters:
value
- object to be evaluatedcondition
- condition to compareresult
- expected resultjsonPath
- jsonPath under evaluation (to provide more info when an assertion fails)
-
runCommandAndGetResult
public void runCommandAndGetResult(String command) throws Exception
- Throws:
Exception
-
runCommandLoggerAndEnvVar
public void runCommandLoggerAndEnvVar(int exitStatus, String envVar, Boolean local)
-
getVariable
public String getVariable(String variable)
Returns the value of the given placeholder as used in the gherkin stepExamples:
getVariable("${variable}") //returns the java property, same as doing System.getProperty("variable") getVariable("!{variable}") //returns the thread property, same as doing ThreadProperty.get("variable") getVariable("#{variable}") //returns the corresponding value from the properties file. getVariable("@{variable}") //returns attribute value
- Parameters:
variable
- Variable placeholder as used in the gherkin file- Returns:
- Value assign to that variable
- See Also:
ReplacementAspect.replacePlaceholders(String, boolean)
-
-