Hi Team,
I am able to fetch the request of the session validation
exec { session => {
val fulfillOrderId = session("fulfillOrderId").as[String]
session.set("getFulfillOrderId",s"${fulfillOrderId}_containerList")
.set(s"${fulfillOrderId}_containerList", session("containerList").as[Seq[String]])
}
here fulfillOrderId=1440794
Hence session value is correcly fetching as “1440794_containerList → Vector(D10421))”
But when I retrieve and use this in foreach loop, it is not accepting.
exec {
session =>
val fulfill = session.get("fulfillOrderId").as[String]
val abc = fulfill + "_containerList"
val x: Seq[String] = session.get(s"${fulfill}_containerList".toString).as[Seq[String]]
println("x:"+x)
exec {
// println("hi"+"*******************")
session =>
exec {
foreach(x, "containerNumber") {
println("Inside for looping" + "${containerNumber}" + "*****" + fulfill + "******" + abc)
exec {
//Assign container
Here the value x is printing as expected (x:Vector(D10421)) But it is not getting subsituted in sequence.
Can you please help me how to pass the sequence in foreach
Since the “println” isn’t a part of the Gatling DSL, it’s unlikely it’ll know how to deal with the “${containerNumber}”. Can you try this instead ?
println("Inside for looping" + session("containerNumber").as[String] + "*****" + fulfill + "******" + abc)
https://gatling.io/docs/2.3/session/expression_el/
regards,
Aju
1 Like
Thanks Aju for your reply.
def assignContainers() =
exec {
session =>
val fulfill = session.get("fulfillOrderId").as[String]
val abc = fulfill + "_containerList"
val x: Seq[String] = session.get(s"${fulfill}_containerList".toString).as[Seq[String]]
println("x1:"+x)
exec {
// println("hi"+"*******************")
session =>
exec {
foreach(x, "containerNumber") {
println("Inside for looping1" + session("containerNumber").as[String] + "*****" + fulfill + "******" + abc)
exec {
//Assign container
http("Assign_container_to_the_user_and_order")
.put(s"${url}/gif-cloud-storage-manager/v1/containers")
.body(StringBody(
"""{
> "operationType": "assign",
> "containers": [
> {
> "containerNumber": "${containerNumber}",
> "temperatureBandCode": 4,
> "containerLocationName":"LOCATION",
> "fulfillOrderId":${fulfillOrderId}
> }
> ]
>}""".stripMargin)).asJSON
.header(HttpHeaderNames.Accept, HttpHeaderValues.ApplicationJson)
.header(HttpHeaderNames.AcceptLanguage, "en-${countryCode}")
.header("X-countryCode", "${countryCode}")
.header("X-nodeId", "${nodeId}")
.header("X-consumerId", "E2E")
.header("X-UserId", "${fulfillOrderId}")
.check(status.is(201))
}
}
}
session
}
session
}
Even now, it is not wokring. I am unable to go inside the foreach loop
I tried foreach(x,"containerNumber) and foreach(x.seq, “containerNumber”) both seems not working. what else I am missing.