Hi All,
Question >> How to Generate formparam based the session variable size where both the key and values are dynamic
Work Around >>
def method1 = {
pause(monitoringConstant.pauseMin, monitoringConstant.pauseMax)
.exec(http("CaptureRandomMessageId")
.get("Get_Url")
.check(status.is("200"), jsonPath("$..id").findAll.saveAs("key_indicators"))
.check(status.is("200"), jsonPath("$..version").findAll.saveAs("version"))
.check(status.is("200"), jsonPath("$..index").findAll.saveAs("index"))
.check(status.is("200"), jsonPath("$..message_id").findAll.saveAs("message_id_selected")))
}
def method2(messageStatus: String, messageResolve: String) = {
pause(monitoringConstant.pauseMin, monitoringConstant.pauseMax)
// Passing the dynamic value to the server (In progress working on the better solution)
.doIfEquals("${key_indicators.size()}", 1) {
exec(http("Take Action On Message")
.patch("Post_Url")
.headers(headers.HeadersObj.messageTakeActionHeaders)
.formParam("batch[0][keyIndicatorId]", "${key_indicators(0)}")
.formParam("batch[0][status]", messageStatus)
.formParam("batch[0][resolve]", messageResolve)
.formParam("batch[0][assignee]", "admin")
.formParam("status", messageStatus)
.formParam("resolve", messageResolve)
.formParam("version", "${version(0)}")
.formParam("assignee", "admin")
.formParam("db_index_id", "${index(0)}")
.formParam("alerts_only", "true")
.check(status.is(monitoringConstant.successStatus)))
.pause(monitoringConstant.pauseMin, monitoringConstant.pauseMax)
}
.doIfEquals("${key_indicators.size()}", 2) {
exec(http("Take Action On Message")
.patch("Post_Url")
.headers(headers.HeadersObj.messageTakeActionHeaders)
.formParam("batch[0][keyIndicatorId]", "${key_indicators(0)}")
.formParam("batch[0][status]", messageStatus)
.formParam("batch[0][resolve]", messageResolve)
.formParam("batch[0][assignee]", "admin")
.formParam("batch[1][keyIndicatorId]", "${key_indicators(1)}")
.formParam("batch[1][status]", messageStatus)
.formParam("batch[1][resolve]", messageResolve)
.formParam("batch[1][assignee]", "admin")
.formParam("status", messageStatus)
.formParam("resolve", messageResolve)
.formParam("version", "${version(0)}")
.formParam("assignee", "admin")
.formParam("db_index_id", "${index(0)}")
.formParam("alerts_only", "true")
.check(status.is(monitoringConstant.successStatus)))
}
.pause(monitoringConstant.pauseMax)
.doIfEquals("${key_indicators.size()}", 3) {
exec(http("Take Action On Message")
.patch("Post_Url")
.headers(headers.HeadersObj.messageTakeActionHeaders)
.formParam("batch[0][keyIndicatorId]", "${key_indicators(0)}")
.formParam("batch[0][status]", messageStatus)
.formParam("batch[0][resolve]", messageResolve)
.formParam("batch[0][assignee]", "admin")
.formParam("batch[1][keyIndicatorId]", "${key_indicators(1)}")
.formParam("batch[1][status]", messageStatus)
.formParam("batch[1][resolve]", messageResolve)
.formParam("batch[1][assignee]", "admin")
.formParam("batch[2][keyIndicatorId]", "${key_indicators(2)}")
.formParam("batch[2][status]", messageStatus)
.formParam("batch[2][resolve]", messageResolve)
.formParam("batch[2][assignee]", "admin")
.formParam("status", messageStatus)
.formParam("resolve", messageResolve)
.formParam("version", "${version(0)}")
.formParam("assignee", "admin")
.formParam("db_index_id", "${index(0)}")
.formParam("alerts_only", "true")
.check(status.is(monitoringConstant.successStatus)))
}
.pause(5)
.doIfEquals("${key_indicators.size()}", 4) {
exec(http("Take Action On Message")
.patch("Post_Url")
.headers(headers.HeadersObj.messageTakeActionHeaders)
.formParam("batch[0][keyIndicatorId]", "${key_indicators(0)}")
.formParam("batch[0][status]", messageStatus)
.formParam("batch[0][resolve]", messageResolve)
.formParam("batch[0][assignee]", "admin")
.formParam("batch[1][keyIndicatorId]", "${key_indicators(1)}")
.formParam("batch[1][status]", messageStatus)
.formParam("batch[1][resolve]", messageResolve)
.formParam("batch[1][assignee]", "admin")
.formParam("batch[2][keyIndicatorId]", "${key_indicators(2)}")
.formParam("batch[2][status]", messageStatus)
.formParam("batch[2][resolve]", messageResolve)
.formParam("batch[2][assignee]", "admin")
.formParam("batch[3][keyIndicatorId]", "${key_indicators(3)}")
.formParam("batch[3][status]", messageStatus)
.formParam("batch[3][resolve]", messageResolve)
.formParam("batch[3][assignee]", "admin")
.formParam("status", messageStatus)
.formParam("resolve", messageResolve)
.formParam("version", "${version(0)}")
.formParam("assignee", "admin")
.formParam("db_index_id", "${index(0)}")
.formParam("alerts_only", "true")
.check(status.is(monitoringConstant.successStatus)))
}
.pause(monitoringConstant.pauseMin, monitoringConstant.pauseMax))
}
My issues here is how to form formparam dynamically when both key and values are dynamic based on the size of the key_indicators/any ?