How to validate response using script assertion when the Rest Response has multiple nodes?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to validate response using script assertion when the Rest Response has multiple nodes?
Trying to perform an End to End Test using readyapi/soap ui pro, if any solution please advise..
- I have rest URI as http:localhost/DataRequest1/DataRequest2/DataRequest3. All the Data request I have created as a Template.
- I created a test step 'Data Source' & 'Data Source Loop' and passed data.
TestCaseStatus | DataRequest1 | DataRequest2 | DataRequest3 | Response1 | Response2 |
A001 | B001 | C001 | D001 | E001 | |
A002 | B002 | C002 | D002 | E002 | |
A001 | B001 | C001 | D003 | E003 | |
A002 | B002 | C002 | D004 | E004 | |
A001 | B001 | C001 | D005 | E005 | |
A002 | B002 | C002 | D006 | E006 |
- In response I have getting response in below JSON if I perform 1st Step as Rest request
Reuest URI: http:localhost/A001/B001/C001.
Response JSON:
[
{
"DataRequest1": "A001",
"DataRequest2": "B001",
"DataRequest3": "C001",
"Response1": "D001",
"Response2": "E001"
},
{
"DataRequest1": "A001",
"DataRequest2": "B001",
"DataRequest3": "C001",
"Response1": "D003",
"Response2": "E003"
},
{
"DataRequest1": "A001",
"DataRequest2": "B001",
"DataRequest3": "C001",
"Response1": "D005",
"Response2": "E005"
}
]
As you see on the above I get multiple responses on a request. My challenge is to validate whether I am getting the response correctly or not in form of Script Assertion and store it as a TestCaseStatus for each iteration from the Data Source Step and validate the response with property response on Data Source Step.
Any suggestions please?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://stackoverflow.com/questions/31472381/dynamically-compare-rest-xml-json-response-and-jdbc-usin...
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rao,
I have a challenge here in building JDBC request, I am using Mongo Client and there is no inbuilt JDBC congiguration for MongoDB.
My expectations are listed in the DataSource step. I have to compare the JSON response with respective to Data Source Step.
Regards,
Saradhi
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the connection string use the mango documentation.
Good luck.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Rao,
I have downloaded and placed the files in the respective directory.
I have written groovy script (Named the script as Script1) for retrieving values from Database. I added one more groovy script and trying to access the response from the groovy script in the new script, but I was getting 'null' value.
Any suggestions please.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to put everything in the same script, now challenge arises on assertion. I am not able to compare below database and rest responses getting assertion failed. Please advise.
Database Groovy Script response
{
"_id" : {"$oid" : "57560fb04c4013fef4e31d20"} ,
"Datarequest1" : "A001" ,
"Datarequest2" : "B001" ,
"Datarequest3" : "C001" ,
"Response1" : "D001" ,
"Response2" : "E001"
}
{
"_id" : {"$oid" : "57560fb04c4013fef4e31d20"} ,
"Datarequest1" : "A001" ,
"Datarequest2" : "B001" ,
"Datarequest3" : "C001" ,
"Response1" : "D003" ,
"Response2" : "E003"
}
{
"_id" : {"$oid" : "57560fb04c4013fef4e31d20"} ,
"Datarequest1" : "A001" ,
"Datarequest2" : "B001" ,
"Datarequest3" : "C001" ,
"Response1" : "D005" ,
"Response2" : "E005"
}
REST Response:
[{"id":"57560fb04c4013fef4e31d20",
"Datarequest1":"A001",
"Datarequest2":"B001",
"Datarequest3":"C001",
"propertyKey":"D001",
"propertyValue":"E001"
},
{"id":"57560fb04c4023fef4e31d20",
"Datarequest1":"A001",
"Datarequest2":"B001",
"Datarequest3":"C001",
"propertyKey":"D003",
"propertyValue":"E003"},
{"id":"5761aa6a02d875aeb096bc22",
"Datarequest1":"A001",
"Datarequest2":"B001",
"Datarequest3":"C001",
"propertyKey":"D005",
"propertyValue":"E005"}]
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to put everything in the same script, now challenge arises on assertion. I am not able to compare below database and rest responses getting assertion failed. Please advise.
Database Groovy Script response
{
"_id" : {"$oid" : "57560fb04c4013fef4e31d20"} ,
"Datarequest1" : "A001" ,
"Datarequest2" : "B001" ,
"Datarequest3" : "C001" ,
"Response1" : "D001" ,
"Response2" : "E001"
}
{
"_id" : {"$oid" : "57560fb04c4013fef4e31d20"} ,
"Datarequest1" : "A001" ,
"Datarequest2" : "B001" ,
"Datarequest3" : "C001" ,
"Response1" : "D003" ,
"Response2" : "E003"
}
{
"_id" : {"$oid" : "57560fb04c4013fef4e31d20"} ,
"Datarequest1" : "A001" ,
"Datarequest2" : "B001" ,
"Datarequest3" : "C001" ,
"Response1" : "D005" ,
"Response2" : "E005"
}
REST Response:
[{"id":"57560fb04c4013fef4e31d20",
"Datarequest1":"A001",
"Datarequest2":"B001",
"Datarequest3":"C001",
"propertyKey":"D001",
"propertyValue":"E001"
},
{"id":"57560fb04c4023fef4e31d20",
"Datarequest1":"A001",
"Datarequest2":"B001",
"Datarequest3":"C001",
"propertyKey":"D003",
"propertyValue":"E003"},
{"id":"5761aa6a02d875aeb096bc22",
"Datarequest1":"A001",
"Datarequest2":"B001",
"Datarequest3":"C001",
"propertyKey":"D005",
"propertyValue":"E005"}]
