I need to mock the call to onStatus. The probelem is that I am getting the below error.
org.mockito.exceptions.misusing.PotentialStubbingProblem: Strict stubbing argument mismatch. Please check:
when(responseSpec.onStatus(HttpStatus::isError,(clientResponse) -> {
if (clientResponse.statusCode() == HttpStatus.resolve(402)) {
return Mono.error(new Exception("402"));
}
if (clientResponse.statusCode() == HttpStatus.resolve(500)) {
return Mono.error(new Exception("500"));
}
if (clientResponse.statusCode() == HttpStatus.resolve(512)) {
return Mono.error(new Exception("512")));
}
return Mono.error(new Exception("Error while processing request"));
}))
.thenReturn(responseSpec);
}