Forum Discussion

richie's avatar
richie
Community Hero
6 years ago

Assert every instance of a json attribute displays a specific pattern

Hey,   nmrao gave me some code to assert that a repeating attribute in my json response had a null as follows:: assert context.response, 'Request parameter is correct' def json = new groovy.jso...
  • nmrao's avatar
    6 years ago

    richie 

     

    You already have the list and it can be asserted as below.

     

    Note that used fixed list to demonstrate

     

     

    def list = ['ABC', 'PQR', 'GDS']
    assert list.every{it ==~ /[A-Z]{3}/}

    So, instead of list varible in the above, use your derivated list i.e., json.data.DataSourceName