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.
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
I want to iterate through the reponse and compare the values to the DB. How can i do this?
Solved! Go to Solution.
was able to get the reponse to print like this
the result was
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?
From jdbc also you would get arraylist.
And use assert to compare both the lists. Make sure both lists are sorted before the assert.
Below assert will do the compare actual vs expected.
assert expected == actual, "Not matching"
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.
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.
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
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
and some links to process json provided in below thread, see Message 5
Hope these links helps.