-
-
Save dragoonis/813d5b9ee507e336e0e3a92afcdd7bad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.asLongAs(session => session.contains("foundDocuments") == false) { | |
// Loop over every client and request their documents. | |
foreach("${siriusAssignedClientIds}", "siriusAssignedClientId") { | |
exec( session => { | |
// as[Map[String, String]] | |
val assignedClient = session("assignedClient").as[Map[String, String]] | |
println("LOOP START - assignedClientId is: " + assignedClient); | |
session.set("assignedClientId", assignedClient("id")) | |
}) | |
// @todo - > jsonPath($.documents[*].id).findAll.transform.exists, found nothing - if finds nothing, don't error out. | |
.exec( | |
http("ALL DOCUMENTS FOR A CLIENT") | |
// .get("/api/v1/persons/${siriusRandomAssignedClientId}/documents?limit=999&sort=createdDate:desc,id:desc&filter=draft:0") | |
.get("/api/v1/persons/${siriusAssignedClientId}/documents?limit=999&sort=createdDate:desc,id:desc&filter=draft:0") | |
.headers(apiHeaders) | |
.check(status.is(200)) | |
.check(jsonPath("$.documents") | |
.ofType[Map[String, Any]] | |
.findAll | |
.saveAs("siriusAssignedDocuments") | |
) | |
) | |
.exitHereIfFailed | |
// https://gist.github.com/ivanursul/78404db87c2d2334db55 | |
// Here we loop all the found documents and request them | |
.doIf(session => session("siriusAssignedDocuments").as[Map[String, Any]].size > 0) { | |
// @todo - we're getting some kind of Type Mismatch here on this exec | |
// // 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("foundDocuments", "true") | |
// Randomize the available documents to this user, and set it back into the session, so the foreach() picks this up | |
session.set("siriusAssignedDocuments", util.Random.shuffle(session("siriusAssignedDocuments"))) | |
session | |
}) | |
// Iterate all of the client's documents | |
.foreach("${siriusAssignedDocuments}", "assignedDocument") { | |
// We need to pluck out the documentId from the next item in the foreach(), which is stored in the session | |
exec( session => { | |
// as[Map[String, String]] | |
val assignedDocument = session("assignedDocument").as[Map[String, Any]] | |
println("assignedDocument from the session:" + assignedDocument); | |
session.set("assignedDocumentId", assignedDocument("id")) | |
session | |
}) | |
.exec( | |
http("GET DOCUMENT") | |
.get("/api/document/${assignedDocumentId}/file") | |
.headers(pdfHeaders) | |
.check(status.is(200)) | |
) | |
.exitHereIfFailed | |
} | |
} // /doIf | |
// } // /doIf | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment