'hook-1' crashed with 'j.u.NoSuchElementException: No attribute named 'orderId' is defined', forwarding to the next one - Gatling
Есть скрипт Gatling на Scala
val workload: ScenarioBuilder = scenario("PostCreateCorpCoOrder")
.feed(simcards)
.feed(userIdFeeder)
.feed(partnerIdFeeder)
.exec(http("PostCreateCorpCoOrder")
.post("/b2b/v1/ccs-web/api/createCorpCoOrder")
.body(ElFileBody("b2b/createCorpCoOrderRequest.json"))
.check(
status.in(200, 500),
jsonPath("$.orderId").exists.saveAs("orderId")
jsonPath("$.orderId").saveAs("orderId")
checkIf(substring("unique constraint").find.exists == true) {
jsonPath("$.code").saveAs("errorCode")
}
)
)
.doIfOrElse(session =>
session("errorCode").asOption[String].nonEmpty
) {
exec {
session =>
jsonPath("$.message").saveAs("errorMes")
scala.tools.nsc.io.File("/data/gatling/b2b_results/notValidSimCards_" + timestamp + ".txt").appendAll(session("errorMes").as[String] + "\n")
session
}
}{
exec {
session =>
scala.tools.nsc.io.File("/data/gatling/b2b_results/orderIDs_" + timestamp + ".txt").appendAll(orderId + "\n")
session
}
}
Если мне возвращается ответ
{"code":5050,"message":"PreparedStatementCallback; SQL [\nINSERT INTO ICCIDS\nVALUES (?,\n ?,\n ?)\n]; ORA-00001: unique constraint (B2B_CORPCS.SYS_C0010866) violated\n; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (B2B_CORPCS.SYS_C0010866) violated\n","product":"b2b","service":"CorpCS","operation":"createCorpCoOrder"}
Нужно определять, что есть подстрока unique constraint и записывать сообщение в файл notValidSimCards_ + timestamp. Это не работает вообще. Подскажите, почему?
Если мне приходит успешный ответ
{
"orderStatus": "PROCESSING",
"orderType": "MASS_ACT_SIM",
"orderCreateDate": "2022-08-23T20:51:05.280133+03:00",
"orderId": 9078
}
Нужно записывать orderId в файл orderIDs_ + timestamp. Тут вообще всё удивительно. Я использую специально метод optional, потому что JsonPath может не всегда срабатывать. Но при этом, когда НУЖНО, он выдаёт ошибку:
i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-2' crashed with 'j.u.NoSuchElementException: No attribute named 'orderId' is defined', forwarding to the next one
JSONPath проверял несколько раз на разных примерах
Очень прошу помощи, ковыряю этот скрипт уже 3 дня