using a feeder in a custom validation function


I use the next scenario

def getPath(id: String): String = s"/content/prod${id}"

def getRequestBody(currentId: String): String = {

def getCheck(expected: String): HttpCheck =
bodyString.validate(_ => buildMatcher(expected))

val feeder = Iterator.continually(Map(“idR” → random))

http(“PUT ${idR}”)
status is 200
.pause(1 seconds)
http(“GET ${idR}”)

with the custom functions for request body, url, checks. For body and url it works fine as the results are the strings, but for check it doesn’t work. I understand why(Warning This Expression Language only works on the final value that is passed to the DSL method when the Simulation is instantiated.) but I dont understand the way for use this with a custom validation function. Could you help me?
P.S. sorry for my english.

First, make getCheck take an Expression[String] instead of a String, so implicit EL conversion gets triggered.
Then, instead of discarding (underscore) the session input of the lambda you pass to validate, use it :slight_smile:

def getCheck(expected: Expression[String]): HttpCheck =
bodyString.validate(session => expected(session).map(resolvedExpected => buildMatcher(resolvedExpected))

Thank you, it works fine.

Have a nice day!

Great :slight_smile:
Have fun