Forum Discussion

richie's avatar
richie
Community Hero
6 years ago

Not Contains Assertion (JSON attribute value) - not XML

Hey,   I've been investigating the Not Contains assertion to verify that a json attribute does NOT contain a specific value.   HOWEVER - all the posts I've seen on this on this forum/stackove...
  • nmrao's avatar
    nmrao
    6 years ago

    richie ,

     

    Here is the script assertion for the same.

     

    If I understand right, the value of "entityLogicalName" should not be "appointment". And below script checks that.

     

    /**
    * Below is the script assertion for the REST Request Test step
    **/
    def json = new groovy.json.JsonSlurper().parseText(context.response)
    def logicalNames = json.sessiondata.'appointment.nhs_slottype'.entityLogicalName
    def checkFor = 'appointment'
    //Negative check - value should not have appointment "!=", 
    //Positive check -  use "==" to match value with appointment
    assert logicalNames.every {it != checkFor}, "Not expecting value ${checkFor} for entityLogicalName, but found"