diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 85b318112..230491cc0 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -137,7 +137,7 @@ }, { "id": "request-storage", - "version": "6.0", + "version": "6.1", "handlers": [ { "methods": ["GET"], diff --git a/ramls/request.json b/ramls/request.json index aa582e033..f2fbfd1a4 100644 --- a/ramls/request.json +++ b/ramls/request.json @@ -18,6 +18,11 @@ "type": "string", "enum": ["Hold", "Recall", "Page"] }, + "ecsRequestPhase": { + "description": "Stage in ECS request process, absence of this field means this is a single-tenant request", + "type": "string", + "enum": ["Primary", "Secondary"] + }, "requestDate": { "description": "Date the request was made", "type": "string", diff --git a/src/test/java/org/folio/rest/api/RequestsApiTest.java b/src/test/java/org/folio/rest/api/RequestsApiTest.java index 14521c857..cf2435013 100644 --- a/src/test/java/org/folio/rest/api/RequestsApiTest.java +++ b/src/test/java/org/folio/rest/api/RequestsApiTest.java @@ -1958,6 +1958,46 @@ public void cannotCreateRequestWithoutStatus() ))); } + @Test + public void canCreateRequestWithEcsRequestPhase() throws MalformedURLException, + ExecutionException, InterruptedException, TimeoutException { + + JsonObject representation = createEntity( + new RequestRequestBuilder() + .page() + .primary() + .withId(UUID.randomUUID()) + .create(), + requestStorageUrl()).getJson(); + assertThat(representation.getString("ecsRequestPhase"), is("Primary")); + + representation = createEntity( + new RequestRequestBuilder() + .page() + .secondary() + .withId(UUID.randomUUID()) + .create(), + requestStorageUrl()).getJson(); + assertThat(representation.getString("ecsRequestPhase"), is("Secondary")); + } + + @Test + public void shouldReturn400IfInvalidEcsRequestPhase() throws MalformedURLException, + ExecutionException, InterruptedException, TimeoutException { + + var request = new RequestRequestBuilder() + .page() + .withEcsRequestPhase("Invalid") + .withId(UUID.randomUUID()) + .create(); + + CompletableFuture createCompleted = new CompletableFuture<>(); + client.post(requestStorageUrl(), request, TENANT_ID, ResponseHandler.json(createCompleted)); + + assertThat(createCompleted.get(5, TimeUnit.SECONDS).getStatusCode(), is(400)); + } + + private RequestDto.RequestDtoBuilder holdShelfOpenRequest() { return RequestDto.builder() .requesterId(UUID.randomUUID().toString()) diff --git a/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java b/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java index ccb8f60c6..d849b35e3 100644 --- a/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java +++ b/src/test/java/org/folio/rest/support/builders/RequestRequestBuilder.java @@ -52,6 +52,7 @@ public class RequestRequestBuilder extends JsonBuilder { private final String patronComments; private final UUID holdingsRecordId; private final SearchIndex searchIndex; + private final String ecsRequestPhase; public RequestRequestBuilder() { this(UUID.randomUUID(), @@ -79,6 +80,7 @@ public RequestRequestBuilder() { null, null, UUID.randomUUID(), + null, null); } @@ -101,6 +103,7 @@ public JsonObject create() { put(request, "requestExpirationDate", this.requestExpirationDate); put(request, "holdShelfExpirationDate", this.holdShelfExpirationDate); put(request, "pickupServicePointId", this.pickupServicePointId); + put(request, "ecsRequestPhase", this.ecsRequestPhase); if (this.itemSummary != null) { final JsonObject item = new JsonObject(); @@ -204,7 +207,8 @@ public RequestRequestBuilder withNoId() { this.tags, this.patronComments, this.holdingsRecordId, - this.searchIndex); + this.searchIndex, + this.ecsRequestPhase); } public RequestRequestBuilder toHoldShelf() { @@ -247,7 +251,8 @@ public RequestRequestBuilder withItem(RequestItemSummary item) { this.tags, this.patronComments, this.holdingsRecordId, - this.searchIndex); + this.searchIndex, + this.ecsRequestPhase); } public RequestRequestBuilder withRequester( @@ -282,7 +287,8 @@ public RequestRequestBuilder withRequester( this.tags, this.patronComments, this.holdingsRecordId, - this.searchIndex); + this.searchIndex, + this.ecsRequestPhase); } public RequestRequestBuilder withRequester( @@ -316,7 +322,8 @@ public RequestRequestBuilder withRequester( this.tags, this.patronComments, this.holdingsRecordId, - this.searchIndex); + this.searchIndex, + this.ecsRequestPhase); } public RequestRequestBuilder withProxy( @@ -350,7 +357,8 @@ public RequestRequestBuilder withProxy( this.tags, this.patronComments, this.holdingsRecordId, - this.searchIndex); + this.searchIndex, + this.ecsRequestPhase); } public RequestRequestBuilder withNoPosition() { return withPosition(null); @@ -375,4 +383,12 @@ private class PatronSummary { } } + public RequestRequestBuilder primary() { + return withEcsRequestPhase("Primary"); + } + + public RequestRequestBuilder secondary() { + return withEcsRequestPhase("Secondary"); + } + }