Skip to content

Commit

Permalink
Merge branch 'master' into tmp-release-17.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kapil-epam authored Jan 13, 2025
2 parents 3493be2 + e65afba commit 6c39931
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ramls/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Usage: SELECT normalize_isbns(jsonb->'identifiers') FROM instance
-- This takes each ISBN, normalizes it using RMB's normalize_digits(text),
-- and concatenates the results using a space as separator.
CREATE OR REPLACE FUNCTION normalize_isbns(jsonb_array jsonb) RETURNS text AS $$
SELECT string_agg(normalize_digits(identifiers->>'value'), ' ')
CREATE OR REPLACE FUNCTION ${myuniversity}_${mymodule}.normalize_isbns(jsonb_array jsonb) RETURNS text AS $$
SELECT string_agg(${myuniversity}_${mymodule}.normalize_digits(identifiers->>'value'), ' ')
FROM jsonb_array_elements($1) as identifiers
WHERE identifiers->>'identifierTypeId' = '8261054f-be78-422d-bd51-4ed9f33c3422';
$$ LANGUAGE sql IMMUTABLE PARALLEL SAFE STRICT;
27 changes: 27 additions & 0 deletions src/test/java/org/folio/rest/api/RequestUpdateTriggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -55,6 +57,31 @@ void beforeEach() throws MalformedURLException {
StorageTestSuite.deleteAll(requestStorageUrl());
}

@Test
@SneakyThrows
void isDcbReRequestCancellationShouldBePresentAfterRequestUpdated() {
CompletableFuture<JsonObject> 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",
Expand Down

0 comments on commit 6c39931

Please sign in to comment.