use of org.folio.circulation.support.ForwardOnFailure in project mod-circulation by folio-org.
the class RequestByInstanceIdResourceTests method getExpectedErrorMessages.
@Test
void getExpectedErrorMessages() {
HttpFailure validationError = ValidationErrorFailure.singleValidationError(new ValidationError("validationError", "someParam", "null"));
String errorMessage = RequestByInstanceIdResource.getErrorMessage(validationError);
assertTrue(errorMessage.contains("validationError"));
HttpFailure serverErrorFailure = new ServerErrorFailure("serverError");
errorMessage = RequestByInstanceIdResource.getErrorMessage(serverErrorFailure);
assertEquals("serverError", errorMessage);
HttpFailure badRequestFailure = new BadRequestFailure("badRequestFailure");
errorMessage = RequestByInstanceIdResource.getErrorMessage(badRequestFailure);
assertEquals("badRequestFailure", errorMessage);
Response fakeResponse = new Response(500, "fakeResponseFailure", "text/javascript");
HttpFailure forwardOnFailure = new ForwardOnFailure(fakeResponse);
errorMessage = RequestByInstanceIdResource.getErrorMessage(forwardOnFailure);
assertEquals("fakeResponseFailure", errorMessage);
}
use of org.folio.circulation.support.ForwardOnFailure in project mod-circulation by folio-org.
the class UpdateRequestQueueTest method assertFailedOnFailureResponse.
private <T> void assertFailedOnFailureResponse(CompletableFuture<Result<T>> completableFuture) throws Exception {
Result<T> result = completableFuture.get(5, TimeUnit.SECONDS);
assertTrue(result.failed());
assertTrue(result.cause() instanceof ForwardOnFailure);
ForwardOnFailure forwardResponse = (ForwardOnFailure) result.cause();
assertThat(forwardResponse.getFailureResponse(), is(serverErrorBatchResponse));
}
use of org.folio.circulation.support.ForwardOnFailure in project mod-circulation by folio-org.
the class PatronActionSessionRepository method delete.
public CompletableFuture<Result<PatronSessionRecord>> delete(PatronSessionRecord session) {
var interpreter = new ResponseInterpreter<PatronSessionRecord>().on(204, of(() -> session)).otherwise(response -> {
log.info("Error has occurred while deleting PatronSessionRecord with id {} and action type {}", session.getId(), session.getActionType().name());
return failed(new ForwardOnFailure(response));
});
log.info("Deleting {}", session);
return patronActionSessionsStorageClient.delete(session.getId().toString()).thenApply(flatMapResult(interpreter::apply));
}
Aggregations