Я пытаюсь проверить следующие два вызова REST:
Запрос 1
GET getLatestVersion
Response: {"version": 10}
Запрос 2
POST getVersionData (body={"version": 10})
Response: {"version": 10, data: [...]}
Можно ли присвоить «версию» из запроса 1 переменной для использования в запросе 2 в рамках того же теста?
@CitrusTest(name = "SimpleIT.getVersionTest")
public void getVersionTest() {
// Request 1
http()
.client("restClient")
.send()
.get("/getLatestVersion")
.accept("application/json");
http()
.client("restClient")
.receive()
.response(HttpStatus.OK)
.messageType(MessageType.JSON)
// Can the version be assigned to a variable here?
.payload("{\"version\":10}");
// Request 2
http()
.client("restClient")
.send()
.post("/getVersionData")
// Idealy this would be a Citrus variable from the previous response
.payload("{\"version\":10}")
.accept("application/json");
http()
.client("restClient")
.receive()
.response(HttpStatus.OK)
.messageType(MessageType.JSON)
.payload("\"version\": 10, data: [...]");
}