Forum Discussion

chathurad's avatar
chathurad
Contributor
6 years ago
Solved

Validate availability of atleaset one item

After doing some basic scripting like this 

def response = context.expand( '${Request 1#Response}' ).toString()
def slurper = new JsonSlurper()
def json = slurper.parseText response

def courseType = json.result.courseType
log.info(courseType )

 

I got the out put somthing like this where each note is having few course types.

I need to validate whether each group contains  "General English" on it.

 

 

Fri Aug 17 14:22:04 IST 2018:INFO:[["General English","40+","Exams","Academic","Cambridge","Teacher Training"], ["Cambridge","Academic","Exams","General English"], ["General English","Academic","Business","Exams","Cambridge","40+"], ["General English","Cambridge","Exams","Academic","Teacher Training"], ["General English","Cambridge","Exams","Teacher Training","Business"], ["Business","Cambridge","Academic","Exams","General English"], ["General English","40+","Exams","Academic","Cambridge","Teacher Training"], ["General English","Exams","Academic","Cambridge"], ["General English","Exams"]]4

 

 

  • courseType.each { assert it.contains("General English") }

2 Replies

  • JHunt's avatar
    JHunt
    Community Hero
    courseType.each { assert it.contains("General English") }
    • chathurad's avatar
      chathurad
      Contributor

      Few minuts ago i did the same but little bit different way, But your answer is correct.

      Thanks again.