When I try to mock a javax.ws.rs.core Response
I get a error message:
Unable to create a JAX-RS runtime Delegate
Why does this happen?
Response response = Mockito.mock(Response.class);
But when I try to mock a HttpServletResponse there is no issue with that!
HttpServletResponse response1 = Mockito.mock(HttpServletResponse.class);
You can try with a fake response like this:
ResponseBuilder responseBuilder = Response.ok();
when(client.form(any(Form.class))).thenReturn(responseBuilder.entity("his is a string").build();
In this snippet "when" is a mockito method, and responseBuilder object return a simple string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With