From 47caef7d5ce6c567310b340aba92d3a425e4a437 Mon Sep 17 00:00:00 2001 From: Antony Hruschev Date: Mon, 16 Dec 2024 13:49:06 +0400 Subject: [PATCH] CIRCSTORE-552 Implement the code for the feature UXPROD-5001 (#501) CIRCSTORE-552 Implement the code for the feature UXPROD-5001 --- ramls/request.json | 4 +++ .../rest/api/RequestUpdateTriggerTest.java | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ramls/request.json b/ramls/request.json index 7083f5211..86cb26b07 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -282,6 +282,10 @@ "itemLocationCode": { "description": "Allow specifying item location when creating title-level requests", "type": "string" + }, + "isDcbReRequestCancellation": { + "description": "Indicates if the request was cancelled during a DCB transaction update. This determines whether the Kafka event will be handled and if an email notification will be sent", + "type": "boolean" } }, "additionalProperties": false, diff --git a/src/test/java/org/folio/rest/api/RequestUpdateTriggerTest.java b/src/test/java/org/folio/rest/api/RequestUpdateTriggerTest.java index cf80c655e..eaa1ab131 100644 --- a/src/test/java/org/folio/rest/api/RequestUpdateTriggerTest.java +++ b/src/test/java/org/folio/rest/api/RequestUpdateTriggerTest.java @@ -22,12 +22,14 @@ import io.vertx.core.json.JsonObject; import io.vertx.sqlclient.Row; import io.vertx.sqlclient.RowSet; +import lombok.SneakyThrows; import org.joda.time.DateTime; import org.joda.time.Seconds; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; @@ -55,6 +57,31 @@ void beforeEach() throws MalformedURLException { StorageTestSuite.deleteAll(requestStorageUrl()); } + @Test + @SneakyThrows + void isDcbReRequestCancellationShouldBePresentAfterRequestUpdated() { + CompletableFuture future = new CompletableFuture<>(); + + String id = "3a57dc83-e70d-404b-b1f1-442b88760331"; + Request request = new Request() + .withStatus(fromValue(Request.Status.OPEN_NOT_YET_FILLED.toString())); + + assertThat(request.getIsDcbReRequestCancellation(), is(nullValue())); + + saveRequest(id, request) + .compose(v -> updateRequest(id, request + .withStatus(fromValue(Request.Status.CLOSED_CANCELLED.toString())) + .withIsDcbReRequestCancellation(Boolean.TRUE))) + .compose(v -> getRequest(id)) + .onComplete(updatedRequest -> future.complete(updatedRequest.result())); + + JsonObject updatedRequest = future.get(5, TimeUnit.SECONDS); + + assertThat(updatedRequest.getString("isDcbReRequestCancellation"), + is(notNullValue())); + + } + @ParameterizedTest @CsvSource(value = { "Open - Awaiting pickup | Closed - Pickup expired",