Hey nmrao
Ok - sorry - I'm still working on the project which you provided an script assertion on a JDBC test step to extract a DB table's column and it's value and insert it to a property in a Properties step. This is also the project in which you provided me a script to build and publish a request grabbing Query Parameter and values from the Properties step.
My requests have the following pattern:
/api/1/{namespace}/{dataset}?QueryParm=value
As well as the GET request searching for a record that is filtered for a specific QueryParm value (using the syntax pattern above), there is also the requirement for the system to support wildcard searches like the following:
"contains" (where QueryParm value 'contains' a specific value)
"starts with" (where QueryParm value 'starts with' a specific value)
"ends with" (where QueryParm value 'ends with' a specific value)
Using the Name attribute (jsonpath = $.['data']['Name']) in the attached json as an example, there are 2 records in there where Name = Richard, and 2 records where the Name = nmrao.
The syntax to specify a 'contains' is to specify the ~ character before the QueryParm value.
SO - if the Name attribute contains records with the Name attribute value of 'Richard', I could use the following request to retrieve those records:
/api/1/{namespace}/{dataset}?Name=~ich
similarly the 'starts with' operator requires the ^ character before the QueryParameter value - so again using "Name":"Richard" as the example, the request would appear as
/api/1/{namespace}/{dataset}?Name=^Ric
FinalIy the 'ends with' operator requires the $ character before the QueryParameter value - so again using "Name":"Richard" as the example, the request would appear as
/api/1/{namespace}/{dataset}?Name=$ard
The perfect option is updating the Script Assertion you gave me that extracts the Property value from the database - but updating your script assertion was completely beyond my skills - so I thought I might be able to put a bit of groovy together to update the property value AFTER your script assertion had written it to the Properties step (essentially cos I'm trying to not annoy you with all my questions! :))
So - currently my Test Case object hierarchy is as follows:
JDBC Request: (query retrieves a single record's column and its associated value and the script assertion writes this to the Properties step)
Properties: (contains the resultant of the script assertion)
Groovy REST Request Step: (builds the request, grabbing the contents of the Properties step to build the Query Parameters in my request's query string)
I was thinking of putting an extra groovy script together (with my attempt to grab a substring of the Property value grabbed by your script assertion) to pass this to the groovy script that builds and publishes the request so that my test case hierarchy would be as follows:
JDBC Request: (with script assertion)
Properties: (contains results of script assertion)
Groovy step: (containing my attempt to grab a substring of the value stored in 'Properties' and write the substr value out to another Properties step (entitled 'Properties 2')
Properties 2: (contains the substring value
Groovy REST Request Step: (builds the request, grabbing the contents of the Properties 2 step to build the Query Parameters in my request's query string)
Obviously if my REST request was using the OTB functionality, it would be easy to prefix the value sourced from a properties step with a $ or ~ or ^ character - but I can't because I'm using the groovy to build and submit the request.
I've attached an updated .json response file to reflect the Name attribute details I used above
I've also attached the groovy step code you created to build and publish the request
I've also attached the script assertion you gave me
I hope I've been a little clearer,
As always I appreciate your time,
richie