{ if (res.failed){ handler.handle(Fut" /> { if (res.failed){ handler.handle(Fut" /> { if (res.failed){ handler.handle(Fut"/>

Writing test case for vert.x WebClient in java

38 Views Asked by At

I have this code in a function in java vert.x.

WebClient.getAbs(url).putHeader("auth_token",authToken).send(res->{
if (res.failed){
handler.handle(Future.failedFuture(""));
return;
}
// Processing response body
});

I wanted to write a test case for this in Java.

I tried this to mock that:

doAnswer(invocationOnMock -> {
Handler<AsyncResult<HttpResponse<Buffer>>> resultHandler = invocationOnMock.getArgument(0);
resultHandler.handle(Future.failedFuture(""));
     return null;
}).when(webClient).getAbs(anyString()).send(any());

But getting null pointer exception from doAnswer. How to solve this issue? I am using Junit framework for testing.

0

There are 0 best solutions below