How to check that list of values contains value from previous request?

Hiya,

I’m using gatling to load test a service I written which exposes JSON. The first request returns an object something like:

{
“id” 4"
}

The second request returns a list of elements, something like:

[
{
“type”:“NEW”,
“id”:1,

},
{
“type”:“NEW”,
“id”:4,

},
{
“type”:“DELETED”,
“id”:2,

},
{
“type”:“FINISHED”,
“id”:3,

}
]

I want to check that in the second request there’s an id with type “NEW” that matches the id returned by the first request. I don’t think any of the current checks documented in the verify section of the wiki can do this. How would you usually check this kind of functionality?

Thanks, Helen

Hi,

I’ve just backported Gatling 2 JsonPath engine so that one can target the root array. I hope to release 1.4.6 tomorrow, so stay tuned.

You can generate the expression of the second check from the result of the first one:

  • check(jsonpath("/id").saveAs(“id”)) // save the id from the first request

  • check(jsonpath("/_[type=‘NEW’][id=’${id}’]")) // reuse it in the second one to build the JsonPath expression (note that _ means “root array”, only available in 1.4.6)

Cheers,

Stéphane