newbie gatling dumb json validation question

Hi all,
I’ve done my first bit of gatling and I need to verify the results of parsed json. I did a lot of searching and couldn’t see how, but I suspect I was missing the obvious (it was getting very late).
My gatling code now doesn’t work due to 2nd party problems, which hopefully will be fixed soon, so I can’t run or test anything but if anyone can show me how to get this working it will make gatling a lot more interesting to my colleagues, and we need a load tester soon.

OK, my code is

val getUnmodifiedAttribs =
exec(http(“get unmodified attribs”)
.get(http://localhost:9000/files/${fileCreatedID}/Attributes)
.check( jsonPath("$[*].value").findAll.saveAs(“tmpjson”) )
.check( jsonPath("$[*].value").count.is(8) )

The above verifies the json is length 8. I need next verify it contains expected results, preferably in scala as the checks may get very involved.

If the answer is on the web please point me at. I repeatedly read the docs but couldn’t see it. So sorry if this is obvious to everyone else, but how is this done?

cheers

jan

I’d really appreciate some pointers. If necessary I’ll do it in WGet scripts; it has to be done somehow, but i’d prefer using a decent tool.
If it’s a particularly stupid question, forgive me, but I did do a lot of searching before posting here.

cheers

jan

If you need complex validation, you’ll probably need to write your own Validator.

Now, this is a community mailing list. If you need fast and accurate answer from the experts and what you can get from good willed community members doesn’t meet your needs, we at GatlingCorp can help with professional services.

Thanks, when looking around I did see a blog where someone wrote something similar, but I couldn’t handle that level of scala yet - nor quite see the need. I just want to escape to scala, with the value retrieved, turn it into a boolean and have Gatling’s .check proceed based on that.

If that can’t be done in Gatling, I need to know so I can switch to something else. I find it impossible to imagine that it can’t be easily done given Gatling’s front-end is just chained library calls.

It did occur to me, too late to try, that a transformer might be the way to do it?

cheers

jan

Once again, yes, it’s possible and not that complicated.
Just use validate, pass it a Validator, which is basically a function from Option[T] to Validation[Option[T]]

If you can write a function from T to Boolean, you should able to write such method.

Another solution would be to use transform but then you’d only be able to save the transformed value.

Thanks so much! I’ll try to get to this ASAP

cheers

jan