Hi,
I am working on REST apis and I have a problem. Records in my response are sorted randomly.
{ "status": "success", "messages": [ { "date_created": "Sat, 06 Jun 2015 18:29:15 +0000", "text": "Your booking is confirmed for 4 guests on Thursday, June 4 at Motel6", "status": "delivered", "dateCreated": "2015-06-06T18:29:15.000Z", "priceUnit": "USD" }, { "date_created": "Sat, 06 Jun 2015 19:28:12 +0000", "text": "Your booking is confirmed for 2 guests on Thursday, June 4 at Motel6", "status": "delivered", "dateCreated": "2015-06-06T19:28:12.000Z", "priceUnit": "USD" }, { "date_created": "Sat, 06 Jun 2015 18:29:01 +0000", "text": "Your booking is confirmed for 1 guest on Thursday, June 4 at Motel6", "status": "not delivered", "dateCreated": "2015-06-06T18:29:01.000Z", "priceUnit": "USD" } ], "page_size": 50 }
Here's what I would like to do
1. Get current system time (For example "2015-06-06T19:28:05.000Z")
2. Compare it against all records (data value either from date_created or dateCreated) with absolute error of 15 seconds
3. When first match found (second record in the above request), take first part of “text” node value ("Your booking is confirmed for") and compare it against test case parameter “success text”.
Could any one please suggest how this can be written in Groovy?