I am using json as a feeder as “.queue()” and have a key “timestamp” in it.
Now while creating the scenario I have below code. I have tried to pass the as EL in json directly or replace with in the .body() but nothing seems to be working for me.
I am sure there is quick trick on this, please share if you know.
Note: I cannot load as json file (and use elfilebody), there are some calculations I am doing on top of this code and json file contains multiple array of information which i am using as iterative payloads.
Gatling Expression Language (Gatling EL) is not magic. Only the Gatling API is aware of it.
When dealing with classic methods (such as String::replace in your sample code), you need to use the Session API yourself.
This is the reason (your calculation) you need to transform the json yourself.
Either by directly modifying the string, or using an external JSON library.
But I guess that your calculations may be done before (in a session => session function as your 2nd line) before introducing it in a JSON pattern file read by ElFileBody.
I have tried elfilebody passing #{currentDate(yyyy-MM-dd’T’HH:mm:ss)} with “.body(ElFileBody(“supplyEvents0.json”))” in scenario. This works, I know. This is a different situation.
My situation current is different. I have bunch of json files, in each json file there are bunch of AOEvents. the size of AOEvent also varies within each file. So what i have done is based on the size of AOEvent per json file, I have created iterators, coz these are unique transactions and cannot be run in circular and has to be in .queue().
Every time i read a single AOEvent, it gives me map and for that I am converting it to .jsonStringify() uisng built-in function.
Now when i read a single AOEvent, I also have to replace a field ‘LastTransDate’ for current date. And for this in my below code you will notice i am creating a session key ‘timestamp’ in the session before iterating the AOEvent block of that file. and then here I have need to replace the value of the object.
I have tried with direct replace() and also by placing value “${timestamp}” in the json tile for key ‘LastTransDate’.
And this is where I need some directions, based on this situation, not some other approach of designing the test. Coz I have already come far long in script, and changing approach will be very difficult and thats how I get file from upstream application, can’t do much to the way i get these files…
Also I don’t need millisecond, i need the whole date in this format ‘#{currentDate(yyyy-MM-dd’T’HH:mm:ss)}’
Thank you Stephane for this direction… I will try it out… I have to gain familiarity with this new way… I will explore and keep this group posted.
thanks!!!
But this could be a good feature to add to your list. This is complex but imagine if user can handle this in one syntax. It will help companies with complex architectures.