I am getting this error which I am not sure what it means:
Type mismatch. Required: session.Expression[Boolean], found: Validation[CheckBuilder[JsonPathCheckType, JsonNode, String] with SaveAs[JsonPathCheckType, JsonNode, String]]
I am trying to retrieve a value called "title" from an API response body for a user's created assessment and save it as "titleSession". Because not every user that is fed into the simulation will have associated created assessments I am trying to make the saving of "titleSession" only occur if there already exists a "title", hence the doIf:
private val manifestInfoQuickAssign = getManifestInfoForCreatingAssessement
.check(status.is(Ok),
doIf(jsonPath("$.results[*].matches.assessment[*].title").find.exists()){
jsonPath("$.results[*].matches.assessment[*].title").saveAs(titleSession)
}
)
For context, here are the current Gatling imports I have imported:
import io.gatling.core.Predef.exec
import io.gatling.core.Predef._
import io.gatling.core.structure.ChainBuilder
import io.gatling.http.Predef._
Also here is "getManifestInfoForCreatingAssessment":
val getManifestInfoForCreatingAssessement = http("Get custom assessment metadata (Manifest-Resources) resources")
.get("/api/onesearch/v1/metadata")
.headers(getHeaderMap)
.queryParam("collection", "Assessments")
.queryParam("options", "search-assessments-json") //search-assessments-json for ui possibly
.queryParam("start", "1")
.queryParam("pageLength", "1000")
.queryParam("searchView", "results")
.queryParam("q", "userId:${userId} sort:title")
.check(status is Ok,
jsonPath("$.total").saveAs("totalAssessments"))
If anyone knows how to save the "title" if it exists, even without the doIf or resolve the error, that would be great. Thank you.
This is wrong, you can't use doIf
there.
You're looking for the optional
validation criterion: https://gatling.io/docs/gatling/reference/current/http/check/#validating