BMCIM
7 years agoOccasional Contributor
Date Assertions
Hi
My JSON response (rest request) returns a date. I need to verify the date returned is less than 1/1/1969.
How do I do this?
All replies are much appreciated.
Thanks in advance.
Hi
My JSON response (rest request) returns a date. I need to verify the date returned is less than 1/1/1969.
How do I do this?
All replies are much appreciated.
Thanks in advance.
You can use a script assertion, just change the jsonpath and format as needed.
jsonpath = '$..path[0]' format = 'M/d/yyyy' import static com.jayway.jsonpath.JsonPath.parse
response = parse(messageExchange.response.contentAsString)
result = response.read(jsonpath)
date = Date.parse(format, result)
assert date < Date.parse(format, '1/1/1969')