use of io.nem.symbol.sdk.openapi.vertx.invoker.ApiException in project nem2-sdk-java by nemtech.
the class AbstractVertxRespositoryTest method mockErrorCodeRawResponse.
/**
* Mocks the api client telling that the next time there is remote call, an error should be
* returned.
*
* @param statusCode the status code of the response (404 for example)
* @param errorResponse the raw response, it may or may not be a json string.
*/
protected void mockErrorCodeRawResponse(int statusCode, String errorResponse) {
String reasonPhrase = HttpStatus.valueOf(statusCode).getReasonPhrase();
VertxHttpHeaders headers = new VertxHttpHeaders();
ApiException exception = new ApiException(reasonPhrase, statusCode, headers, errorResponse);
Mockito.doAnswer((Answer<Void>) invocationOnMock -> {
Handler<AsyncResult<Object>> resultHandler = (Handler<AsyncResult<Object>>) invocationOnMock.getArguments()[invocationOnMock.getArguments().length - 1];
resultHandler.handle(Future.failedFuture(exception));
return null;
}).when(apiClientMock).invokeAPI(Mockito.anyString(), Mockito.anyString(), Mockito.anyList(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
}
Aggregations