Reputation: 99
I have the response method which i need to validate, So i have included the Conditional Statement, But however i am getting the script error as "Type mismatch: cannot convert from HttpClientResponseActionBuilder to boolean",
if(http()
.client(todoClient)
.receive()
.response(HttpStatus.OK).validate("$.statusCode", "200")) {
For Report Purpose
}
else {
For Report Purpose
}
Is there a better way to achive what i am looking for.
Regards BJ
Upvotes: 0
Views: 107
Reputation: 2216
Your code does not compile because http() Java fluent API is not returning a boolean
value here. So you can not place that in an if
statement here.
You could make use of conditional
test action containers instead. I am thinking of saving the Http status response code to a test variable. You can then use several conditional containers based on that response code value.
http().client(todoClient)
.receive()
.response()
.extractFromHeader(HttpMessageHeaders.HTTP_STATUS_CODE, "statusCode");
conditional()
.when("${statusCode} = 200")
.actions(echo("Everything OK!"));
conditional()
.when("${statusCode} = 404")
.actions(echo("NOT FOUND!"));
Upvotes: 1