Skip to content

Commit

Permalink
Merge pull request #204 from folio-org/CIRCSTORE-156
Browse files Browse the repository at this point in the history
CIRCSTORE-156: add a flag for recall due date modification
  • Loading branch information
mreno-EBSCO authored Sep 16, 2019
2 parents 4bf3fc2 + 39a1716 commit e1d6c06
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 18 deletions.
2 changes: 1 addition & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"provides": [
{
"id": "loan-storage",
"version": "6.1",
"version": "6.2",
"handlers": [
{
"methods": ["GET"],
Expand Down
2 changes: 1 addition & 1 deletion ramls/loan-storage.raml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#%RAML 1.0
title: Loan Storage
version: v6.1
version: v6.2
protocols: [ HTTP, HTTPS ]
baseUri: http://localhost:9130

Expand Down
4 changes: 4 additions & 0 deletions ramls/loan.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 37 additions & 0 deletions src/test/java/org/folio/rest/api/LoansApiTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -39,6 +40,7 @@ public LoanRequestBuilder() {
null,
null,
null,
null,
null);
}

Expand All @@ -56,7 +58,8 @@ private LoanRequestBuilder(
UUID loanPolicyId,
DateTime returnDate,
DateTime systemReturnDate,
Integer renewalCount) {
Integer renewalCount,
Boolean dueDateChangedByRecall) {

this.id = id;
this.itemId = itemId;
Expand All @@ -72,6 +75,7 @@ private LoanRequestBuilder(
this.returnDate = returnDate;
this.systemReturnDate = systemReturnDate;
this.renewalCount = renewalCount;
this.dueDateChangedByRecall = dueDateChangedByRecall;
}

public static LoanRequestBuilder from(JsonObject example) {
Expand Down Expand Up @@ -135,7 +139,8 @@ public static LoanRequestBuilder from(JsonObject example) {
loanPolicyId,
returnDate,
systemReturnDate,
renewalCount);
renewalCount,
example.getBoolean("dueDateChangedByRecall"));
}

@Override
Expand Down Expand Up @@ -196,6 +201,10 @@ public JsonObject create() {
request.put("actionComment", actionComment);
}

if (dueDateChangedByRecall != null) {
request.put("dueDateChangedByRecall", dueDateChangedByRecall);
}

return request;
}

Expand All @@ -214,7 +223,8 @@ public LoanRequestBuilder withId(UUID newId) {
this.loanPolicyId,
this.returnDate,
this.systemReturnDate,
this.renewalCount);
this.renewalCount,
this.dueDateChangedByRecall);
}

public LoanRequestBuilder withNoId() {
Expand All @@ -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) {
Expand All @@ -254,7 +265,8 @@ public LoanRequestBuilder withUserId(UUID userId) {
this.loanPolicyId,
this.returnDate,
this.systemReturnDate,
this.renewalCount);
this.renewalCount,
this.dueDateChangedByRecall);
}

public LoanRequestBuilder withNoUserId() {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -312,7 +326,8 @@ public LoanRequestBuilder withStatus(String statusName) {
this.loanPolicyId,
this.returnDate,
this.systemReturnDate,
this.renewalCount);
this.renewalCount,
this.dueDateChangedByRecall);
}

public LoanRequestBuilder open() {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -428,7 +448,8 @@ public LoanRequestBuilder withSystemReturnDate(DateTime systemReturnDate) {
this.loanPolicyId,
this.returnDate,
systemReturnDate,
this.renewalCount);
this.renewalCount,
this.dueDateChangedByRecall);
}

public LoanRequestBuilder withNoStatus() {
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}

0 comments on commit e1d6c06

Please sign in to comment.