How to assert or validate the sorting order of a response json data on SoapUI
For a get request im getting a json response and it contain some school data.The schools should be appear by descending order for the school rating number.
Somthing looks like this.
"result":[
{
"location": "Sydney",
"minStudentAge": 13,
"schoolType": "Business",
"rating": 5,
},
{
"location": "Sydney",
"minStudentAge": 16,
"schoolType": "Business",
"rating": 3,
},
{
"location": "Sydney",
"minStudentAge": 18,
"schoolType": "Business",
"rating": 1,
},
{
"location": "Sydney",
"minStudentAge": 16,
"schoolType": "Business",
"rating": 2, }
]
So every node is having a value named "Rating" and i need to validate whether the return json contains data on correct order. Rating top (5) should be at the top of the list and rating low (1) should be at the bottom of the list.
I did somthing like this,
import com.eviware.soapui.support.XmlHolder
import net.sf.*;
import net.sf.json.*;
import net.sf.json.groovy.*;
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
//Getting response from methods
def response = context.expand( '${Schools#Response}' ).toString()
But after this what should i do?
Hi,
It just looks like you didn't put in the correction I mentioned in my second post above.
Attached is a project with a working example.