Compare response to table values
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compare response to table values
I have a response(i have multiple such entries copied only one.) like below and I have a table that I need to compare it against.
{
"Items": [
{
"EmployeeId": "1",
"CompanyId": "1",
"FirstName": "SPENCER",
"LastName": "LIN"
"Status": {
"Code": "A",
"Description": "Active"
},
"BenefitClass": null,
"SupervisorId": null,
"SupervisorFirstName": null,
"SupervisorLastName": null,
"CostCenters": [
{
"Code": "01",
"Description": "Corporate"
}
]
}
I was able to print the results of the value in DB, like below:
/*****************************************this is the employeeId returned from DB.**************************************/
def returntripDB = getEmployeeFromDB(db,jsonRes)
returned DB value[[Id:1], [Id:113], [Id:129], [Id:130], [Id:131], [Id:134], [Id:136], [Id:140], [Id:143]]
public def getEmployeeFromDB(def database,jsonRes)
{
def query = "SELECT Id FROM [mydb].[mydb].[etable] order by etableid asc"
// log.info "QUERY for all employee id only "+query
return database.rows(query)
}
I want to iterate through the reponse and compare the values to the DB. How can i do this?
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
was able to get the reponse to print like this
jsonRes.Items.EmployeeId.each
{
//groovy iterator
def valueOfEmployee=it.value
log.info myResponsevalues
}
the result was
1
113
129
130
131
134
136
Also I was able to get the DB results like below //log.info "DB values"+returntripDB
DB values[1, 113, 129, 130, 131]
How can I compare these two values?
please help
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From jdbc also you would get arraylist.
And use assert to compare both the lists. Make sure both lists are sorted before the assert.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I dont have a JDBC step.. how can i add this query result to an Array ? and compare the two
can you please help.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Below assert will do the compare actual vs expected.
assert expected == actual, "Not matching"
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The limitation in this apporach is, if i write method to compare two values (without assertion) and want to print to results (html results), it is not possible. That is the drawback with SoapUI tool.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Regardless of 'matching or not matching', if I use log.info("My comment"), it won't be printed to Html Reports. ( Let us say, we followed your suggestion - single test step, and calling it mutliple times because only some data change.)
I was told, this is not possible. The result will just diplay the overall testcase result, not step-wise.
Instead, if I create each step as a test case, and if I use assert, then it will go into HTML reports.
thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
lets please stick to the original question... folks can you please help me on this its been 3 days and am hunting for the solution. This morning I have 2 issues my iterator of the reponse isnt printing results
1.my iterator is not printing result which it did earlier
jsonRes.Items.EmployeeId.each
{
//groovy iterator
def valueOfEmployee=it.value
log.info myResponsevalues
}
Issue 2 : how do i add the results of database return and the above to an arrays and compare the results. Hit a blank wall.please help
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://stackoverflow.com/questions/31472381/dynamically-compare-rest-xml-json-response-and-jdbc-usin...
and some links to process json provided in below thread, see Message 5
http://community.smartbear.com/t5/SoapUI-Open-Source/Extracting-data-from-CData-in-SOAP-Response/m-p...
Hope these links helps.
Regards,
Rao.
