//commented below as we are testing with fixed data
//def jsonText = context.response

def jsonText = '''{
  "cars": [
    {
      "name" : "Jetta",
      "brand" : "Volkswagen"
    },
    {
      "name" : "Polo GT",
      "brand" : "Volkswagen"
    },
    {
      "name" : "i30",
      "brand" : "Hyundai"
    }
  ]
}'''


def brandToCheck = 'Volkswagen'
def expectedCars = ['Jetta', 'Polo GT']



def cars = new groovy.json.JsonSlurper().parseText(jsonText).cars

assert expectedCars == cars.findAll { it.brand == brandToCheck }.name, 'Not matching the expected cars'


//User want to validate brand of i30

assert 'Hyundai' == cars.find { it.name == 'i30'}.brand, 'Not matching the brand for i30 car'