Skip to content

Commit

Permalink
CIRC-2198 Implement the code for the feature UXPROD-5001 (#1521)
Browse files Browse the repository at this point in the history
CIRC-2198 Implement the code for the feature UXPROD-5001
  • Loading branch information
AntonAntonich authored Dec 16, 2024
1 parent 4414f1d commit 511e096
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ramls/request.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@
"itemLocationCode": {
"description": "Allow specifying item location when creating title-level requests",
"type": "string"
},
"isDcbReRequestCancellation": {
"description": "Indicates whether the request was cancelled during a DCB transaction update",
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/folio/circulation/domain/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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;
Expand Down Expand Up @@ -427,6 +428,10 @@ public boolean hasLoan() {
return loan != null;
}

public boolean getDcbReRequestCancellationValue() {
return getBooleanProperty(requestRepresentation, "isDcbReRequestCancellation");
}

public enum Operation {
CREATE, REPLACE, MOVE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ public Result<RequestAndRelatedRecords> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 511e096

Please sign in to comment.