Skip to content

Instantly share code, notes, and snippets.

@dragoonis
Last active Mar 10, 2019
Embed
What would you like to do?
private def hasFoundClientWithDocuments(session: Session): Boolean = {
session.contains("foundClientWithDocuments")
}
.asLongAs(session => hasFoundClientWithDocuments(session) == false) {
// Loop over every client and request their documents.
foreach("${siriusAssignedClientIds}", "siriusAssignedClientId") {
exec(
http("ALL DOCUMENTS FOR A CLIENT")
.get("/api/v1/persons/${siriusAssignedClientId}/documents?limit=999&sort=createdDate:desc,id:desc&filter=draft:0")
.headers(apiHeaders)
.check(status.is(200))
.check(jsonPath("$.total")
.ofType[Int]
.saveAs("numberOfDocuments")
)
.check(jsonPath("$.documents[*].id")
// .ofType[Map[Any, Any]]
.ofType[String]
.findAll
.transform(s => util.Random.shuffle(s))
.saveAs("siriusAssignedDocuments")
)
)
.doIf(session => session("numberOfDocuments").as[Int] > 0) {
// // We verify now that we have found documents for this client, and as such the "asLongAs" loop won't iterater to a new client.
exec( session => {
session.set("foundClientWithDocuments", "true")
})
// Iterate all of the client's documents
.foreach("${siriusAssignedDocuments}", "assignedDocumentId") {
exec(
http("GET DOCUMENT")
.get("/api/document/${assignedDocumentId}/file")
.headers(pdfHeaders)
.check(status.is(200))
)
.exitHereIfFailed
}
} // /doIf
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment