Assertions to verify items are being returned in alphabetical order/ascending/descending order etc
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assertions to verify items are being returned in alphabetical order/ascending/descending order etc
How can I perform assertions on the RESPONSE of a REST API request in order to verify the items (such as DocumentID are being returned in alphabetical order/ascending/descending order etc)
Thanks 🙂
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May be you can find some helpful samples in my github:
https://github.com/nmrao/soapUIGroovyScripts/tree/master/groovy/json
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
After calling a API used for sorting, please see further below the typical JSON Response I need to perform assertions on.
Please note the results for transactionId are being returned in ascending order so I need to perform an assertion on this. I will need to carry out other assertions on new API calls for results being returned in descending order etc.
JSON Response
"results": [
{
"transactionId": 001
"documentNumber": "1234",
"purchaseDate": "2012-05-01T00:00:00",
"uploadedBy": "Kane, Lucy"
},
{
"transactionId": 002,
"userId": "f4b012345678",
"documentNumber": "105343998358653377",
"customerReference": "32145",
"purchaseDate": "2004-12-01T00:00:00",
"uploadedBy": "Mac, Mike"
},
{
"transactionId": 003,
"userId": "f4b0d0c3",
"documentNumber": "1085593563205677",
"purchaseDate": "2006-09-21T00:00:00",
"uploadedBy": "Kelly, Anne"
},
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is an integer. For other API calls I will also need to need to assert on strings (whether they are being returned in ascending/descending order). In other words, I need a solution for both. Thanks.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The response for TransactionId should not include leading zeros (I used dummy data), apologies this is an Integer field. Apologies for the confusion.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Other field names include:-
FileName string
Status string
UploadedBy string
PurchaseDate date-time
Currency String
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
https://github.com/nmrao/soapUIGroovyScripts/blob/master/groovy/json/ArePropertyValuesInOrder.groovy
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just pass required value to "getPropertyValues".
Regards,
Rao.
