ponkipong
is present in activeids
using [Gatling] check - [Scala] ?{
"activeids": [
"ironblossom",
"draw_on",
"ponkipong",
"summer22",
"morphimagus"
]
}
Have tried
.check(jmesPath("activeids[?contains(@, 'ponkipong') == `true`]").transform(_.length >= 1).is(true))
but doesn't work.
Also not sure how to do this using jsonPath.
.check(bodyString.saveAs("response_data"))
.check(
checkIf((response: Response, session: Session) => {
val dde = "ponkipong"
val is_dde_active_not_present = if ((Json.parse(session("response_data").as[String].stripMargin) \ "activeids").as[Seq[String]].indexOf(dde) >= 0) false else true
is_dde_active_not_present
}) {
// this check is to make forceful fail if checkIf fails
jsonPath("$.activeids[*]").count.is(-1)
}
)
But, doesn’t look like a solution.
Need help to do it in a proper way.
Nowadays, I tend to use JMESPath whenever possible, as explained here.
In Scala:
jmesPath("contains(activeids, 'ponkipong')").ofType[Boolean].is(true)
In Java (recommended since Gatling 3.7):
jmesPath("contains(activeids, 'ponkipong')").ofBoolean().is(true)