I would like to use PollingConditions.eventually
to evaluate and return value:
@Shared
static PollingConditions POLLING_CONDITIONS = new PollingConditions(
timeout: 30, delay: 1.5, factor: 1.25
)
MyResponseContainerDto sendRequestWithRetries(String body, String uri) {
ExtractableResponse<Response> extractedResponse = null
POLLING_CONDITIONS.eventually {
extractedResponse = sendRequest(body, uri).extract()
assert extractedResponse.statusCode() == 200
}
return extractedResponse.as(MyResponseContainerDto.class)
}
ValidatableResponse sendRequest(String body, String uri) {
return RestAssured.given()
.contentType(JSON)
.body(body)
.when()
.post("/myApi" + "/" + uri)
.then()
.log().all()
}
When I try to run the above code I get:
Expected a condition, but found an assignment. Did you intend to write '==' ? @ line 42, column 12.
extractedResponse = sendRequest(body, uri).extract()
^
Is there a possibility to have an assignment inside the eventually
block?