From 140a354f21a77287240b902d43b007ea83a8fa2d Mon Sep 17 00:00:00 2001 From: Vignesh-Kalyanasundaram Date: Wed, 31 Jul 2024 20:00:45 +0530 Subject: [PATCH] CIRC-2100 Return 204 for post api and fixing test cases --- .../org/folio/circulation/resources/PrintEventsResource.java | 5 +++-- src/test/java/api/printEvents/PrintEventsTests.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/folio/circulation/resources/PrintEventsResource.java b/src/main/java/org/folio/circulation/resources/PrintEventsResource.java index 72ba78fcd1..605919b60b 100644 --- a/src/main/java/org/folio/circulation/resources/PrintEventsResource.java +++ b/src/main/java/org/folio/circulation/resources/PrintEventsResource.java @@ -13,7 +13,7 @@ import org.folio.circulation.infrastructure.storage.requests.RequestRepository; import org.folio.circulation.support.Clients; import org.folio.circulation.support.RouteRegistration; -import org.folio.circulation.support.http.server.JsonHttpResponse; +import org.folio.circulation.support.http.server.NoContentResponse; import org.folio.circulation.support.http.server.WebContext; import org.folio.circulation.support.results.Result; @@ -24,6 +24,7 @@ import static org.folio.circulation.support.ValidationErrorFailure.singleValidationError; import static org.folio.circulation.support.json.JsonPropertyFetcher.getProperty; +import static org.folio.circulation.support.results.MappingFunctions.toFixedValue; import static org.folio.circulation.support.results.Result.ofAsync; import static org.folio.circulation.support.results.Result.succeeded; @@ -61,7 +62,7 @@ void create(RoutingContext routingContext) { .thenCompose(r -> r.after(validatePrintEventFeatureFlag(circulationSettingsRepository))) .thenCompose(r -> r.after(validateRequests(requestRepository))) .thenCompose(r -> r.after(printEventsRepository::create)) - .thenApply(r -> r.map(response -> JsonHttpResponse.created(null, null))) + .thenApply(r -> r.map(toFixedValue(NoContentResponse::noContent))) .thenAccept(context::writeResultToHttpResponse); } diff --git a/src/test/java/api/printEvents/PrintEventsTests.java b/src/test/java/api/printEvents/PrintEventsTests.java index 4459ad504c..17e4b5d9c3 100644 --- a/src/test/java/api/printEvents/PrintEventsTests.java +++ b/src/test/java/api/printEvents/PrintEventsTests.java @@ -14,7 +14,7 @@ import static api.support.http.InterfaceUrls.printEventsUrl; import static api.support.matchers.ResponseStatusCodeMatcher.hasStatus; -import static org.folio.HttpStatus.HTTP_CREATED; +import static org.folio.HttpStatus.HTTP_NO_CONTENT; import static org.folio.HttpStatus.HTTP_UNPROCESSABLE_ENTITY; import static org.hamcrest.MatcherAssert.assertThat; @@ -29,7 +29,7 @@ void postPrintEventsTest() { JsonObject printRequest = getPrintEvent(); printRequest.put("requestIds", createOneHundredRequests()); Response response = restAssuredClient.post(printRequest, printEventsUrl("/print-events-entry"), "post-print-event"); - assertThat(response, hasStatus(HTTP_CREATED)); + assertThat(response, hasStatus(HTTP_NO_CONTENT)); } @Test