Forum Discussion
raygoel
Occasional Contributor
Thanks for the response!
So, I believe the right way to approach this would be using a for loop?
I used the * operator for JasonSlurper thinking it will iterate over all the elements in the array but guess it works differently from a for loop.
raygoel
4 years agoOccasional Contributor
I fixed the assertions using a for loop
import groovy.json.JsonSlurper
def response = messageExchange.response.responseContent
def slurpedResponse = new JsonSlurper().parseText(response)
def count = slurpedResponse.Size
for(i=0; i< count ; i++) {
if(slurpedResponse[i].isProcess){
if(slurpedResponse[i].name == "Plate1") {
assert slurpedResponse[i].process.name == "UsingProcessPlates"
assert slurpedResponse[i].lid == null
}
if(slurpedResponse[i].name == "Plate2") {
assert slurpedResponse[i].process.name == "UsingProcessPlates"
assert slurpedResponse[i].lid == "Plate2Lid"
}
if(slurpedResponse[i].name == "Plate2Lid") {
assert slurpedResponse[i].process.name == "UsingProcessPlates"
assert slurpedResponse[i].lid == null
}
if(slurpedResponse[i].name == "PlateSet") {
assert slurpedResponse[i].process.name == "UsingProcessPlates"
assert slurpedResponse[i].lid == "PlateSetLid"
}
if(slurpedResponse[i].name == "PlateSetLid") {
assert slurpedResponse[i].process.name == "UsingProcessPlates"
assert slurpedResponse[i].lid == null
}
if(slurpedResponse[i].process.name == "Plate_StallRun") {
assert slurpedResponse[i].process.name == "StallRun"
assert slurpedResponse[i].lid == null
}
}
else {
log.info("The container is not used in any process")
}
}
Thanks for the idea!
I would like to know if there is documentation about different kind of assertions that ReadyAPI offers through scripting. I am okay writing code and would like to explore the assert library more in depth.
Thanks,
Ray
Related Content
- 6 years ago
- 9 years ago