Trying to assert null value in JSON response.
In my below groovy script, it should pass the assert as my Token has some value but it gives me error.
I want when Token has null value then it should failed the assert.
{
"ResponseCode": 1,
"ResponseData": null,
"Result": {
"LoginResult": 2,
"Token": "244F5F16-EB3B-4A58-A784-AE55BF87EA53",
"UserInformation": null
}
}
Groovy script:
import groovy.json.JsonSlurper
def ResponseMessage = messageExchange.response.responseContent
def jsonSlurper = new JsonSlurper().parseText(ResponseMessage)
assert jsonSlurper.Token != null
It gives me error:
assert jsonSlurper.Token != null | | | | null false [Result:[LoginResult:2, Token:244F5F16-EB3B-4A58-A784-AE55BF87EA53, UserInformation:null], ResponseCode:1, ResponseData:null]