How to create a Groovy Script in order to perform assertions for sorting (ascending/descending)
My API response returns customer file details and can sort a chosen field in ascending or descending order.
Example, the JSON REST RESPONSE as detailed further below returns the 'UploadedBy' field as expected in ascending order.
I now need to verify this. Can someone help me with a groovy script for this and PLEASE INCLUDE COMMENTS so that I can completely understand the code, for my own learning purposes.
Thank-you, much appreciated.
JSON RESPONSE
"results": [
{
"trackingEntryId": 24,
"documentId": 24,
"fileId": 24,
"fileName": "Sample.xlsx",
"status": "Success",
"uploadedBy": "Gibson, Mike",
"uploadedDate": "2017-06-21T08:31:23.2021627",
"transactions": 1
},
{
"trackingEntryId": 25,
"documentId": 25,
"fileId": 25,
"fileName": Sample1.xlsx",
"status": "Success",
"uploadedBy": "Hill, Lucy",
"uploadedDate": "2017-06-21T08:32:05.4842927",
"transactions": 1
},
{
"trackingEntryId": 26,
"documentId": 26,
"fileId": 26,
"fileName": "TrackIT_Test4.xlsx",
"status": "Success",
"uploadedBy": "Sinatra, Frank",
"uploadedDate": "2017-06-21T08:33:24.0482512",
"transactions": 0
}
Not a problem, always happy to help. Let me know if you run into issues.