private void waitForTerminationAndDelete(String historyId) throws InterruptedException {
boolean done = false;
int count = 0;
String status = "bla";
JsonPath jsonPath = null;
while (!done) {
Response response =
given()
.header(acceptJson)
.pathParam("hid", historyId)
.expect()
.log().everything()
.when()
.get("/operation/history/{hid}");
jsonPath = response.jsonPath();
status = jsonPath.getString("status");
int code = response.statusCode();
if (code==200 && (status.equals("Success") || status.equals("Failed"))) {
done = true;
} else {
Thread.sleep(2000);
}
count ++;
assert count < 10 :"Waited for 20sec -- something is wrong";
}
if (done && status.equals("Success")) {
Object result = jsonPath.get("result"); // Can not test on result.operationResult, as not every op has this.
assert result != null;
String errorMessage = jsonPath.getString("errorMessage");
assert errorMessage == null;
}
// Delete the history item
given()