diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 87d74126e..13d72a054 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -4,7 +4,7 @@ "provides": [ { "id": "loan-storage", - "version": "6.1", + "version": "6.2", "handlers": [ { "methods": ["GET"], diff --git a/ramls/loan-storage.raml b/ramls/loan-storage.raml index e4f978ebd..7d0e958c6 100644 --- a/ramls/loan-storage.raml +++ b/ramls/loan-storage.raml @@ -1,6 +1,6 @@ #%RAML 1.0 title: Loan Storage -version: v6.1 +version: v6.2 protocols: [ HTTP, HTTPS ] baseUri: http://localhost:9130 diff --git a/ramls/loan.json b/ramls/loan.json index c365d38d6..9cca54426 100644 --- a/ramls/loan.json +++ b/ramls/loan.json @@ -84,6 +84,10 @@ "description": "Patron Group Id at checkout", "type": "string" }, + "dueDateChangedByRecall": { + "description": "Indicates whether or not this loan had its due date modified by a recall on the loaned item", + "type": "boolean" + }, "metadata": { "description": "Metadata about creation and changes to loan, provided by the server (client should not provide)", "type": "object", diff --git a/src/test/java/org/folio/rest/api/LoansApiTest.java b/src/test/java/org/folio/rest/api/LoansApiTest.java index 47ce94b21..a496631a0 100644 --- a/src/test/java/org/folio/rest/api/LoansApiTest.java +++ b/src/test/java/org/folio/rest/api/LoansApiTest.java @@ -1,5 +1,6 @@ package org.folio.rest.api; +import static java.lang.Boolean.TRUE; import static org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isBadRequest; import static org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isNotFound; import static org.folio.rest.support.matchers.LoanMatchers.isClosed; @@ -123,6 +124,42 @@ public void canCreateALoan() //and presents the offset as +0000 (which is ISO8601 compatible, but not RFC3339) assertThat("due date does not match", loan.getString("dueDate"), is("2017-07-27T10:23:43.000+0000")); + + assertThat("recall changed due date should be null", + loan.getBoolean("dueDateChangedByRecall"), nullValue()); + } + + @Test + public void canCreateALoanWithDueDateChangedByRecallSet() + throws MalformedURLException, + InterruptedException, + ExecutionException, + TimeoutException { + + UUID id = UUID.randomUUID(); + UUID itemId = UUID.randomUUID(); + UUID userId = UUID.randomUUID(); + UUID proxyUserId = UUID.randomUUID(); + UUID loanPolicyId = UUID.randomUUID(); + + JsonObject loanRequest = new LoanRequestBuilder() + .withId(id) + .withItemId(itemId) + .withUserId(userId) + .withProxyUserId(proxyUserId) + .withLoanDate(new DateTime(2017, 6, 27, 10, 23, 43, DateTimeZone.UTC)) + .open() + .withAction("checkedout") + .withItemStatus("Checked out") + .withDueDate(new DateTime(2017, 7, 27, 10, 23, 43, DateTimeZone.UTC)) + .withLoanPolicyId(loanPolicyId) + .withDueDateChangedByRecall(TRUE) + .create(); + + JsonObject loan = loansClient.create(loanRequest).getJson(); + + assertThat("recall changed due date is not true", + loan.getBoolean("dueDateChangedByRecall"), is(TRUE)); } @Test diff --git a/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java b/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java index 9375b26f9..57265931d 100644 --- a/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java +++ b/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java @@ -24,6 +24,7 @@ public class LoanRequestBuilder implements Builder { private DateTime returnDate; private DateTime systemReturnDate; private final Integer renewalCount; + private Boolean dueDateChangedByRecall; public LoanRequestBuilder() { this(UUID.randomUUID(), @@ -39,6 +40,7 @@ public LoanRequestBuilder() { null, null, null, + null, null); } @@ -56,7 +58,8 @@ private LoanRequestBuilder( UUID loanPolicyId, DateTime returnDate, DateTime systemReturnDate, - Integer renewalCount) { + Integer renewalCount, + Boolean dueDateChangedByRecall) { this.id = id; this.itemId = itemId; @@ -72,6 +75,7 @@ private LoanRequestBuilder( this.returnDate = returnDate; this.systemReturnDate = systemReturnDate; this.renewalCount = renewalCount; + this.dueDateChangedByRecall = dueDateChangedByRecall; } public static LoanRequestBuilder from(JsonObject example) { @@ -135,7 +139,8 @@ public static LoanRequestBuilder from(JsonObject example) { loanPolicyId, returnDate, systemReturnDate, - renewalCount); + renewalCount, + example.getBoolean("dueDateChangedByRecall")); } @Override @@ -196,6 +201,10 @@ public JsonObject create() { request.put("actionComment", actionComment); } + if (dueDateChangedByRecall != null) { + request.put("dueDateChangedByRecall", dueDateChangedByRecall); + } + return request; } @@ -214,7 +223,8 @@ public LoanRequestBuilder withId(UUID newId) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withNoId() { @@ -236,7 +246,8 @@ public LoanRequestBuilder withItemId(UUID itemId) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withUserId(UUID userId) { @@ -254,7 +265,8 @@ public LoanRequestBuilder withUserId(UUID userId) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withNoUserId() { @@ -276,7 +288,8 @@ public LoanRequestBuilder withProxyUserId(UUID proxyUserId) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withLoanDate(DateTime loanDate) { @@ -294,7 +307,8 @@ public LoanRequestBuilder withLoanDate(DateTime loanDate) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withStatus(String statusName) { @@ -312,7 +326,8 @@ public LoanRequestBuilder withStatus(String statusName) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder open() { @@ -338,7 +353,8 @@ public LoanRequestBuilder withItemStatus(String itemStatus) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withAction(String action) { @@ -356,7 +372,8 @@ public LoanRequestBuilder withAction(String action) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withActionComment(String actionComment) { @@ -374,7 +391,8 @@ public LoanRequestBuilder withActionComment(String actionComment) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withDueDate(DateTime dueDate) { @@ -392,7 +410,8 @@ public LoanRequestBuilder withDueDate(DateTime dueDate) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withReturnDate(DateTime returnDate) { @@ -410,7 +429,8 @@ public LoanRequestBuilder withReturnDate(DateTime returnDate) { this.loanPolicyId, returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withSystemReturnDate(DateTime systemReturnDate) { @@ -428,7 +448,8 @@ public LoanRequestBuilder withSystemReturnDate(DateTime systemReturnDate) { this.loanPolicyId, this.returnDate, systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withNoStatus() { @@ -458,7 +479,8 @@ public LoanRequestBuilder withLoanPolicyId(UUID loanPolicyId) { loanPolicyId, this.returnDate, this.systemReturnDate, - this.renewalCount); + this.renewalCount, + this.dueDateChangedByRecall); } public LoanRequestBuilder withRenewalCount(int renewalCount) { @@ -476,6 +498,26 @@ public LoanRequestBuilder withRenewalCount(int renewalCount) { this.loanPolicyId, this.returnDate, this.systemReturnDate, - renewalCount); + renewalCount, + this.dueDateChangedByRecall); + } + + public LoanRequestBuilder withDueDateChangedByRecall(Boolean dueDateChangedByRecall) { + return new LoanRequestBuilder( + this.id, + this.itemId, + this.userId, + this.proxyUserId, + this.loanDate, + this.statusName, + this.itemStatus, + this.action, + this.actionComment, + this.dueDate, + this.loanPolicyId, + this.returnDate, + this.systemReturnDate, + this.renewalCount, + dueDateChangedByRecall); } }