saving data from response

My simulated device needs to send a confirmation that it executed commands received in a response. Sometimes these commands are present, sometimes they are not. In case they are, this works well

exec(

http(“provisioning”)

.post(localURI)

.headers(headers)

.fileBody(“SyncML-template”,

Map(“vid” → “${vid}”,

“target” → (target + “:80” + localURI),

“sessionid” → “${sessionid}”,

“loopctr” → “${loopctr}”,

“tp” → “${tp}”)).asXML

.check(status.is(200))

.check(xpath("""//pre:SyncBody/pre:Status/pre:Cmd[text()=“SyncHdr”]/following-sibling::pre:Data""", List(“pre” → “SYNCML:SYNCML1.1”)).is(“212”))

.check(xpath("""//pre:SyncBody/pre:Add/pre:CmdID""", List(“pre” → “SYNCML:SYNCML1.1”)).findAll.saveAs(“add-cmdIds”)))

followed after some processing by a doIf with a condition clause on the presence in the session of some attribute derived from add-cmdIds. If the XPath elements are present, the condition evaluates to true and the confirmation request gets sent. If they are not present, the condition evaluates to false and the confirmation request does not get sent. So far, so good. However, the xpath check fails for the provisioning request if there are no commands, i.e. the XPath expression returns the empty set. This is not good - it is perfectly possible that there are no commands, so the this should not be counted as a failed request:

16:35:07.684 [WARN ] c.e.e.g.h.a.GatlingAsyncHandlerActor - Request ‘provisioning’ failed : Check ‘exists’ failed, found Some(ArrayBuffer())

Is there a way in which I can save this data without causing a failure?

Absolutely, exists is just the default.

See “whatever”: https://github.com/excilys/gatling/wiki/Checks#whatever

Note that it is being renamed into dontValidate into upcoming version.