Gatling-Scala : How to consolidated( group strings) from a loop output to a String Array or Vector Array
I need to loop with array value providing string output
consolidated all the retrieved string output as an array
use the consolidated array in next bulk api request.
My logic is not working, kindly help me.
Please help me if there are easier methods with gatling keywords
var i = 0 // initialising i to 0 to increase the array index value in loop
.
.
...check(jsonPath("$.id").saveAs("ArrayValues"))
// saving this array to use in loop and at defining arraylength at last of the loop
//loop
.foreach("#{ArrayValues}", "VValues") {
exec(http("perftest values")
.post("perftest")
.body(StringBody(session =>
s"""{
|"id": "",
|"perfTypeId": "00334-0000-0000-0345",
|"legs":[{
| "valueTypeId": "111-220-3300-0444",
| "values": "${session("VValues").as[String]}"
| }]
| }""".stripMargin)).asJson
.check(jsonPath("$.id").saveAs("perfvalue_singlevalue"))
.check(status.is(201)))
.exec(session => {
val valuearraylen: Vector[String] = session("ArrayValues").as[Vector[String]]
val perfvalue_array: Array[String] = new Array[String](valuearraylen.length)
perfvalue_array(i) = session("perfvalue_singlevalue").as[String]
// ERROR in above logic
// saving value in updated array index
i = i + 1. // moving to next array index
session.set("string_collected_array", perfvalue_array)
})
//provide the created array value to next api request