@Test public void makeResendRequestReturns500() { Invocation.Builder m = restClient.getWebTarget().getMockInvocationBuilder(); doAnswer( (invocation) -> { return Response.serverError().build(); }) .when(m) .post(any(Entity.class)); String targetUrl = "http: ResendRequest request = new ResendRequest(); boolean result = client.makeResendRequest(targetUrl, request); assertThat(result).isFalse(); }
@Override public boolean makeResendRequest(final String targetUrl, final ResendRequest request) { final Entity<ResendRequest> outboundEntity = Entity.entity(request, MediaType.APPLICATION_JSON); try (Response response = client.target(targetUrl).path("/resend").request().post(outboundEntity)) { return Response.Status.OK.getStatusCode() == response.getStatus(); } }
RestResendClient implements ResendClient { @Override public boolean makeResendRequest(final String targetUrl, final ResendRequest request) { final Entity<ResendRequest> outboundEntity = Entity.entity(request, MediaType.APPLICATION_JSON); try (Response response = client.target(targetUrl).path("/resend").request().post(outboundEntity)) { return Response.Status.OK.getStatusCode() == response.getStatus(); } } }
RestResendClient implements ResendClient { @Override public boolean makeResendRequest(final String targetUrl, final ResendRequest request) { final Entity<ResendRequest> outboundEntity = Entity.entity(request, MediaType.APPLICATION_JSON); try (Response response = client.target(targetUrl).path("/resend").request().post(outboundEntity)) { return Response.Status.OK.getStatusCode() == response.getStatus(); } } RestResendClient(final Client client); }
RestResendClient implements ResendClient { @Override public boolean makeResendRequest(final String targetUrl, final ResendRequest request) { final Entity<ResendRequest> outboundEntity = Entity.entity(request, MediaType.APPLICATION_JSON); try (Response response = client.target(targetUrl).path("/resend").request().post(outboundEntity)) { return Response.Status.OK.getStatusCode() == response.getStatus(); } } RestResendClient(final Client client); @Override boolean makeResendRequest(final String targetUrl, final ResendRequest request); }
RestResendClient implements ResendClient { @Override public boolean makeResendRequest(final String targetUrl, final ResendRequest request) { final Entity<ResendRequest> outboundEntity = Entity.entity(request, MediaType.APPLICATION_JSON); try (Response response = client.target(targetUrl).path("/resend").request().post(outboundEntity)) { return Response.Status.OK.getStatusCode() == response.getStatus(); } } RestResendClient(final Client client); @Override boolean makeResendRequest(final String targetUrl, final ResendRequest request);  }