Validate multiple values from Database.
Hi all, I have a bit of a challenge. I am new to soap UI and Groovy scripting. I am comparing few values from my output to the database values. So my test case contains: 1. DataSource which will return few rows. 2. Rest request which will return the json nodes. I am using content assertion to compare values, if the DataSource returns single row my assertion works fine but when there are multiple rows it will only compare 1st row not the other rows. Is there any option to compare multiple rows that are returned?
Example:
My JSON output is something like this:
"parents": [ { "personalTitlePrefix": null, "firstName": "XYZ", "middleName": null, "lastName": "ABC", "generationCodeSuffix": null, "maidenName": null, "gender": "U", "relationship": null, "isPrimaryContact": false }, { "personalTitlePrefix": null, "firstName": "XYZ1", "middleName": null, "lastName": "ABC1", "generationCodeSuffix": null, "maidenName": null, "gender": "U", "relationship": null, "isPrimaryContact": true }, { "personalTitlePrefix": null, "firstName": "XYZ2", "middleName": null, "lastName": "ABC2", "generationCodeSuffix": null, "maidenName": null, "gender": "U", "relationship": null, "isPrimaryContact": true } ],
I need to compare FirstName, LastName,Gender and PrimaryContact values from the database.
Another question is isPrimaryContact value is 1 or 0 in DataBase, where 1 would return true and 0 would be false in Json output. How do I convert them to match the content?
You can use if condition and setting desired values at your script level.
for ex: if DB return 1 then
def dbVal = "YOUR DB QUERY"
if(dbVal == "1"){
dbVal = "true"
}
else{
dbVal = "false"
}