Complex comparison to construct url


I appreciate if I can get some help on this. I need to save the response from 2 requests to construct for the 3rd request, there needs to be some comparisons to figure out the correct value to use for the 3rd request url.

Here is a simplified version of the problem:

http(“Request 1”)

http(“Request 2”)

Now I need to compare for example if key1 is equal to key5, the I will need to use value1 and value5 to construct the 3rd request url. What is the best way to do this comparisons in gatling?

Essentially, if I were to use java, this is like two maps (in sudo code)
map1 = {key1->value1, key2->value2, key3->value3}
map2 = {key4->value4, key5->value5, key6->value6)

to compare the key in map1 to key in map2, if they are equal, the use the value in map1 and value in map2 to construct a url. I know how to do this in java, but i can’t figure out how to write this in gatling, apricate any help or pointers.


I’m not sure what you want to achieve.
But you definitely should look for Session API to be able to save values from one request to another (you already use part of it with your saveAs)
Then, a

  exec { session =>
    if(session("key1").as[String] == session("key5").as[String]) {
      session.set("toUse1", session("value1").as[String]).set("toUse2", session("value2").as[String]) 
    } else ???

Then you will be able to use the two session variables toUse1 and toUse2.

Hope it helps.