Hello everybody,
I am newbie to Gatling and Scala and I need a little help with conditional bahaviour inside ElFileBody.
What I would like to do is to load different files based on a certain condition. Here’s my block of code:
val scnNavigation = scenario(“Perform Navigation”)
.repeat(1) {
feed(csvFeederNavigation)
.exec {
doIfEqualsOrElse("${httpMethod}", “POST”) {
exec (http("${controller} → ${action}")
.post("${controller}/${action}?bankSrgKey=${bankSrgKey}&customerId=${customerId}¶mId=${paramId}¶mType=${paramType}")
.headers(Map(
“Content-Type” → “application/json;charset=UTF-8”,
“Origin” → “http://erm-eca-04”,
“uniqueUserRoleToken” → “${uniqueUserRoleToken}”,
“userSessionToken” → “${userSessionToken}”)
)
.body(
ElFileBody(“bodies/Navigation/${BANK_ID}${paramId}${action}.json”)
)
.check(status.is(200))
.check(bodyString.saveAs(“responseBody”))
).exec { session => println(session(“responseBody”).as[String]); session}
} {
exec (http("${controller} → ${action}")
.get("${controller}/${action}?bankSrgKey=${bankSrgKey}&customerId=${customerId}¶mId=${paramId}¶mType=${paramType}&stepId=${stepId}&roleId=${roleId}&subworkflowId=${subworkflowId}&workflowId=${workflowId}&functionCode=${functionCode}&functionalityId=${functionalityId}&isDeliberating=${isDeliberating}&lvl=${lvl}")
.headers(Map(
“uniqueUserRoleToken” → “${uniqueUserRoleToken}”,
“userSessionToken” → “${userSessionToken}”)
)
.check(status.is(200))
.check(bodyString.saveAs(“responseBody”))
).exec { session => println(session(“responseBody”).as[String]); session}
}
}
}
I need to change the line in bold and to have something like this (the following code throws a type mismatch exception):
.body(
doIfEqualsOrElse("${action}", “GetStepBaseData”) {
val pathFile = “bodies/Navigation/${BANK_ID}${paramId}${stepId}.json”
ElFileBody( pathFile )
} {
val pathFile = “bodies/Navigation/${BANK_ID}${paramId}${action}.json”
ElFileBody( pathFile )
}
)
How can I achieve it?
Thanks in advance,
Matteo