From 4ad823e6b1e567a3457b424d82308a08b5eaa355 Mon Sep 17 00:00:00 2001 From: Antony Hruschev Date: Mon, 16 Dec 2024 13:49:50 +0400 Subject: [PATCH 1/3] Merge the changes for UXPROD-5001 --- ramls/request.json | 4 +++ .../org/folio/circulation/domain/Request.java | 5 +++ .../resources/RequestNoticeSender.java | 10 +++--- .../resources/RequestNoticeSenderTest.java | 36 +++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java diff --git a/ramls/request.json b/ramls/request.json index 9e38fe6c7f..7aca743f34 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -383,6 +383,10 @@ "description": "Request fields used for search", "type": "object", "$ref": "request-search-index.json" + }, + "isDcbReRequestCancellation": { + "description": "Indicates whether the request was cancelled during a DCB transaction update", + "type": "boolean" } }, "additionalProperties": false, diff --git a/src/main/java/org/folio/circulation/domain/Request.java b/src/main/java/org/folio/circulation/domain/Request.java index 0774075a5b..afae370507 100644 --- a/src/main/java/org/folio/circulation/domain/Request.java +++ b/src/main/java/org/folio/circulation/domain/Request.java @@ -27,6 +27,7 @@ import static org.folio.circulation.domain.representations.RequestProperties.REQUEST_LEVEL; import static org.folio.circulation.domain.representations.RequestProperties.REQUEST_TYPE; import static org.folio.circulation.domain.representations.RequestProperties.STATUS; +import static org.folio.circulation.support.json.JsonPropertyFetcher.getBooleanProperty; import static org.folio.circulation.support.json.JsonPropertyFetcher.getDateTimeProperty; import static org.folio.circulation.support.json.JsonPropertyFetcher.getIntegerProperty; import static org.folio.circulation.support.json.JsonPropertyFetcher.getProperty; @@ -406,6 +407,10 @@ public boolean hasLoan() { return loan != null; } + public boolean getDcbReRequestCancellationValue() { + return getBooleanProperty(requestRepresentation, "isDcbReRequestCancellation"); + } + public enum Operation { CREATE, REPLACE, MOVE; } diff --git a/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java b/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java index abbf46c61e..a494a0c8b9 100644 --- a/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java +++ b/src/main/java/org/folio/circulation/resources/RequestNoticeSender.java @@ -119,10 +119,12 @@ public Result sendNoticeOnRequestCancelled( log.debug("sendNoticeOnRequestCancelled:: parameters records: {}", () -> records); Request request = records.getRequest(); - if (request.hasItemId()) { - sendCancellationNoticeForRequestWithItemId(request); - } else { - sendCancellationNoticeForRequestWithoutItemId(request); + if (!request.getDcbReRequestCancellationValue()) { + if (request.hasItemId()) { + sendCancellationNoticeForRequestWithItemId(request); + } else { + sendCancellationNoticeForRequestWithoutItemId(request); + } } return succeeded(records); diff --git a/src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java b/src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java new file mode 100644 index 0000000000..a742d50205 --- /dev/null +++ b/src/test/java/org/folio/circulation/resources/RequestNoticeSenderTest.java @@ -0,0 +1,36 @@ +package org.folio.circulation.resources; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; + +import org.folio.circulation.domain.Request; +import org.folio.circulation.domain.RequestAndRelatedRecords; +import org.folio.circulation.domain.notice.ImmediatePatronNoticeService; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import api.support.builders.RequestBuilder; +import io.vertx.core.json.JsonObject; + +@ExtendWith(MockitoExtension.class) +class RequestNoticeSenderTest { + + @Mock + private ImmediatePatronNoticeService immediatePatronNoticeService; + @InjectMocks + private RequestNoticeSender requestNoticeSender; + + @Test + void shouldNotSendNotificationWhenIsDcbCancellationTrue() { + JsonObject representation = new RequestBuilder().create(); + representation.put("isDcbReRequestCancellation", true); + requestNoticeSender.sendNoticeOnRequestCancelled( + new RequestAndRelatedRecords(Request.from(representation))); + Mockito.verify(immediatePatronNoticeService, times(0)).acceptNoticeEvent(any()); + Mockito.verify(immediatePatronNoticeService, times(0)).sendNotice(any(), any()); + } +} From e65985fdb425b2d7ffdb47a41115d30356a4c18d Mon Sep 17 00:00:00 2001 From: Antony_Hruschev Date: Tue, 28 Jan 2025 11:23:31 +0400 Subject: [PATCH 2/3] [maven-release-plugin] prepare release v24.2.6 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index de9cb8f84f..08737052ff 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 mod-circulation org.folio - 24.2.6-SNAPSHOT + 24.2.6 Apache License 2.0 @@ -295,7 +295,7 @@ https://github.com/folio-org/mod-inventory scm:git:git://github.com:folio-org/mod-inventory.git scm:git:git@github.com:folio-org/mod-inventory.git - v24.2.0 + v24.2.6 From d9985ebcc76c20dc224a206ceb6dbdfa13932ca1 Mon Sep 17 00:00:00 2001 From: Antony_Hruschev Date: Tue, 28 Jan 2025 11:23:32 +0400 Subject: [PATCH 3/3] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 08737052ff..46f88a432d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 mod-circulation org.folio - 24.2.6 + 24.2.7-SNAPSHOT Apache License 2.0 @@ -295,7 +295,7 @@ https://github.com/folio-org/mod-inventory scm:git:git://github.com:folio-org/mod-inventory.git scm:git:git@github.com:folio-org/mod-inventory.git - v24.2.6 + v24.2.0