I want to use a session attribute to determine what chain to execute (via a Map). None of these is valid:
exec(MyMaps.chains("${bar}") //MyMaps.chains is a Map(String, chain)
exec(MyMaps.chains(session(“bar”).as[String])
exec(session => {
MyMaps.chains(session(“bar”).as[String]) //Doesn’t execute
session
})
I also don’t want to use doIf, as I would either have to use a lot of them, or really long inner blocks with lots of copy/pasting involved, and a lot of hard-coded values that would make it unmaintanable:
doIf("${bar}", “foo”) {
exec(FooRequest.req) //The map wouldn’t help here, anyway
}
.doIf("${bar}", “moo”) {
exec(MooRequest.req)
}
If there are 10 requests and I add another value for bar or change moo to boo, it would take forever to update all my scenarios.
Is there any other way I could accomplish this? I also tried using a var bar before declaring the scenario (variable would do just as well as a session attribute), but that a) is shared between users (not the same for all), and b) can’t be changed from within the scenario. I don’t think there’s any way to get a variable with the right scope. (I’m on 2.0.0-snapshot, if it makes a difference.)
For completeness/clarity, Appendix A: the map
object MyMaps {
val chains = Map(
“foo” → FooRequest.req,
“moo” → MooRequest.req
)
}