Reputation: 862
I have a chain of ChainBuilder objects to execute.
In one of them, I'm getting an "id". Then I'm getting a list of tasks and trying to loop through them to find the one I need to complete.
But when I'm doing it like that, it says Type mismatch Expected: ChainBuilder Found: B.
val processTask: ChainBuilder = getTasks
.foreach("${tasks}", "task") {
doIfEquals("${task.id}", "${id}") {
exec(completeTask)
}
}
def getTasks: HttpRequestBuilder = {
http("Get tasks")
.get(tasksUrl)
.check(jsonPath("$[*]").saveAs("tasks"))
}
How to properly loop through the list with a condition?
Upvotes: 1
Views: 1999
Reputation: 6623
.foreach
is a ChainBuilder method and you're trying to invoke it from a HttpRequestBuilder
so it can't compile.
val processTask = exec(getTasks)
.foreach("${tasks}", "task") {
doIfEquals("${task.id}", "${id}") {
exec(completeTask)
}
}
Upvotes: 2