Skip to content

Commit

Permalink
Merge branch 'master' into ecs-tlr-feature
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java
  • Loading branch information
alexanderkurash committed Jun 19, 2024
2 parents 81c55e3 + a204ae1 commit 49d2d1e
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 12 deletions.
8 changes: 6 additions & 2 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"id": "holdings-storage",
"version": "1.3 2.0 3.0 4.0 5.0 6.0"
"version": "1.3 2.0 3.0 4.0 5.0 6.0 7.0"
},
{
"id": "pubsub-event-types",
Expand All @@ -25,6 +25,10 @@
{
"id": "pubsub-publish",
"version": "0.1"
},
{
"id": "configuration",
"version": "2.0"
}
],
"provides": [
Expand All @@ -41,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
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,10 @@
import org.folio.rest.support.ApiTests;
import org.folio.rest.support.http.AssertingRecordClient;
import org.folio.rest.support.http.InterfaceUrls;
import org.folio.rest.support.spring.TestContextConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;

import io.vertx.core.json.JsonObject;
import junitparams.JUnitParamsRunner;

@RunWith(JUnitParamsRunner.class)
@ContextConfiguration(classes = TestContextConfiguration.class)
public class CirculationSettingsAPITest extends ApiTests {

private final AssertingRecordClient circulationSettingsClient =
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
3 changes: 2 additions & 1 deletion src/test/java/org/folio/rest/api/StorageTestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
TlrFeatureToggleJobAPITest.class,
ActualCostRecordAPITest.class,
EventConsumerVerticleTest.class,
CheckOutLockAPITest.class
CheckOutLockAPITest.class,
CirculationSettingsAPITest.class
})
public class StorageTestSuite {

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 49d2d1e

Please sign in to comment.