JaxRsResource extends ResourceBase { protected Response handleExceptions(Supplier<ResponseBuilder> responseBuilder) { return handleExceptions(() -> responseBuilder.get().build(), this::toErrorResponse); }    }
@Test public void handleExceptionsReturnsResponseWhenSuccessful() { try (Response response = resource.handleExceptions(() -> ok("ok"))) { assertThat(response.getStatus(), is(OK.getStatusCode())); assertThat(response.readEntity(String.class), is("ok")); } }
@Test public void handleExceptionsReturnsResponseOnFailure() { try (Response response = resource.handleExceptions(() -> { throw new RuntimeException("error"); })) { assertThat(response.getStatus(), is(INTERNAL_SERVER_ERROR.getStatusCode())); assertThat(response.readEntity(ErrorResponse.class).error, is("error")); } }