Hi I am pretty new to gatling and I have been trying hard to accomplish this simple scenario but I am not able to complete this i dont know how this is done using scala in gatling, I have saved some response in .json file and then i want to just validate those response to a json response.
[
{
“id”: 512,
}
]
this is how my response looks like but this is in array.
object Products {
val jsonFetchProductIDs = ElFileBody(“fetch-products-id.json”)
val fetchProductIds: HttpRequestBuilder = http(“Fetch product ids”).get(“endpoint”)
.body(jsonFetchProductIDs)
val products = http(“Products”)
.get(“endpoint”)
}
class ProductsTest extends Simulation {
val productIdInfo = exec(
Products.products
.check(status.is(200), jsonPath("$.id").ofType[Map[String,Any]].findAll.saveAs(“productsID”))
)
val productIdResult = exec(session => {
val id = session.get(“id”).asOption[String]
foreach("${productsID}", “id”) {
exec(session => {
val idMap = session(“id”).as[Map[String, Any]]
val allId = idMap(" allId")
session.set(“allId”, allId)
})
}
session
})
val getproductidscenario1 = scenario(“Products ID”)
.exec(Login.login)
.exec(EventBus.openSSE)
.exec(Accounts.fetchInitialAccounts)
.pause(10)
.exec(productIdInfo)
.exec(productIdResult)
setUp(
getproductidscenario1.inject(atOnceUsers(1)).protocols(HttpConf.httpConf)
)
}