Hello,
I’m trying to have a simulation pass/succeed based on a result that is aggregated from multiple requests but I’m not sure how to do this.
For example, I’m running:
val products = ArrayBuffer[Integer]
.exec(loginHttpBuilder(username, password)
.check(status.is(200)))
.repeat(5) {
exec(getRecommendationHttpBuilder()
.check(status.is(200))
.check(jsonPath("$recommendation.productId").saveAs(“productId”))
)
.exec((session: Session) => {
val productId = session.attributes(“productId”).asInstanceOf[String].toInt
products.append(productId)
session
})
}
I want to assert that I only got the same product Id once. I’ve tried chaining the following which produces an error statement but does not result in execution failure:
.exec((session: Session) => {
val productMap = products.groupBy { identity }
if (productMap.values.find(_.size > 1).isDefined) Failure(s"Validation failed: ${productMap}") else session
})
How should I go about performing this validation?
Thanks,
Laurent