Skip to content

Commit

Permalink
Circstore 506 (#464)
Browse files Browse the repository at this point in the history
* CIRCSTORE-506 Added isDcb flag in loan.json

* CIRCSTORE-506 added testcases and changes in LoanRequestBuilder

* CIRCSTORE-506 changed the version in moduleDescriptor and loan-storage.raml to 7.3
  • Loading branch information
SreejaMangarapu authored Jun 6, 2024
1 parent 995a4cf commit 5137c20
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 4 deletions.
2 changes: 1 addition & 1 deletion descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
{
"id": "loan-storage",
"version": "7.1",
"version": "7.3",
"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: v7.2
version: v7.3
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 @@ -93,6 +93,10 @@
"description": "Indicates whether or not this loan had its due date modified by a recall on the loaned item",
"type": "boolean"
},
"isDcb": {
"description": "Indicates whether or not this loan is associated for DCB use case",
"type": "boolean"
},
"declaredLostDate" : {
"description": "Date and time the item was declared lost during this loan",
"type": "string",
Expand Down
94 changes: 93 additions & 1 deletion src/test/java/org/folio/rest/api/LoansApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,98 @@ public void canCreateALoan()
}

@Test
public void canCreateALoanForDcb()
throws MalformedURLException,
InterruptedException,
ExecutionException,
TimeoutException {

UUID id = UUID.randomUUID();
UUID itemId = UUID.randomUUID();
UUID itemLocationAtCheckOut = UUID.randomUUID();
UUID userId = UUID.randomUUID();
UUID proxyUserId = UUID.randomUUID();
UUID loanPolicyId = UUID.randomUUID();
DateTime expectedLostDate = DateTime.now();
UUID overdueFinePolicyId = UUID.randomUUID();
UUID lostItemPolicyId = UUID.randomUUID();
final DateTime claimedReturnedDate = DateTime.now(DateTimeZone.UTC);
final DateTime agedToLostDate = DateTime.now(DateTimeZone.UTC).minusDays(10);
DateTime dateLostItemShouldBeBilled = new DateTime(2017, 9, 27, 10, 23, 43, DateTimeZone.UTC);

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))
.withItemEffectiveLocationIdAtCheckOut(itemLocationAtCheckOut)
.withLoanPolicyId(loanPolicyId)
.withDeclaredLostDate(expectedLostDate)
.withOverdueFinePolicyId(overdueFinePolicyId)
.withLostItemPolicyId(lostItemPolicyId)
.withClaimedReturnedDate(claimedReturnedDate)
.withAgedToLostDelayedBilling(false, dateLostItemShouldBeBilled, agedToLostDate)
.withIsDcb(true)
.create();

JsonObject loan = loansClient.create(loanRequest).getJson();

assertThat("dcb property should be true ",
loan.getString("isDcb"), is("true"));
}

@Test
public void canCreateALoanForNonDcb()
throws MalformedURLException,
InterruptedException,
ExecutionException,
TimeoutException {

UUID id = UUID.randomUUID();
UUID itemId = UUID.randomUUID();
UUID itemLocationAtCheckOut = UUID.randomUUID();
UUID userId = UUID.randomUUID();
UUID proxyUserId = UUID.randomUUID();
UUID loanPolicyId = UUID.randomUUID();
DateTime expectedLostDate = DateTime.now();
UUID overdueFinePolicyId = UUID.randomUUID();
UUID lostItemPolicyId = UUID.randomUUID();
final DateTime claimedReturnedDate = DateTime.now(DateTimeZone.UTC);
final DateTime agedToLostDate = DateTime.now(DateTimeZone.UTC).minusDays(10);
DateTime dateLostItemShouldBeBilled = new DateTime(2017, 9, 27, 10, 23, 43, DateTimeZone.UTC);

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))
.withItemEffectiveLocationIdAtCheckOut(itemLocationAtCheckOut)
.withLoanPolicyId(loanPolicyId)
.withDeclaredLostDate(expectedLostDate)
.withOverdueFinePolicyId(overdueFinePolicyId)
.withLostItemPolicyId(lostItemPolicyId)
.withClaimedReturnedDate(claimedReturnedDate)
.withAgedToLostDelayedBilling(false, dateLostItemShouldBeBilled, agedToLostDate)
.withIsDcb(false)
.create();

JsonObject loan = loansClient.create(loanRequest).getJson();

assertThat("dcb property should be false",
loan.getString("isDcb"), is("false"));
}

@Test
public void canCreateALoanWithDueDateChangedByRecallSet()
throws MalformedURLException,
InterruptedException,
Expand Down Expand Up @@ -1483,7 +1575,7 @@ public void canSearchByLoanAgedToLostBillingDate() throws Exception {
.getRecords().stream()
.map(json -> json.getString("id"))
.collect(Collectors.toList());

assertThat(filteredLoans, hasSize(1));
assertThat(filteredLoans, hasItem(loanToBillTomorrow.getId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class LoanRequestBuilder implements Builder {
private final UUID lostItemPolicyId;
private final DateTime claimedReturnedDate;
private final JsonObject agedToLostDelayedBilling;
private final Boolean isDcb;

public LoanRequestBuilder() {
this(UUID.randomUUID(),
Expand All @@ -58,6 +59,7 @@ public LoanRequestBuilder() {
null,
null,
null,
null,
null);
}

Expand Down Expand Up @@ -154,7 +156,9 @@ public static LoanRequestBuilder from(JsonObject example) {
overdueFinePolicyId,
lostItemPolicyId,
claimedReturnedDate,
agedToLostDelayedBilling);
agedToLostDelayedBilling,
example.getBoolean("isDcb")
);
}

@Override
Expand Down Expand Up @@ -242,6 +246,10 @@ public JsonObject create() {
request.put("agedToLostDelayedBilling", agedToLostDelayedBilling);
}

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

return request;
}

Expand Down

0 comments on commit 5137c20

Please sign in to comment.