diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 0b121584..ff14fe6c 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -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", @@ -25,6 +25,10 @@ { "id": "pubsub-publish", "version": "0.1" + }, + { + "id": "configuration", + "version": "2.0" } ], "provides": [ @@ -41,7 +45,7 @@ }, { "id": "loan-storage", - "version": "7.1", + "version": "7.3", "handlers": [ { "methods": ["GET"], diff --git a/ramls/loan-storage.raml b/ramls/loan-storage.raml index c5e6db31..0f49b588 100644 --- a/ramls/loan-storage.raml +++ b/ramls/loan-storage.raml @@ -1,6 +1,6 @@ #%RAML 1.0 title: Loan Storage -version: v7.2 +version: v7.3 protocols: [ HTTP, HTTPS ] baseUri: http://localhost:9130 diff --git a/ramls/loan.json b/ramls/loan.json index a721809f..136137f8 100644 --- a/ramls/loan.json +++ b/ramls/loan.json @@ -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", diff --git a/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java b/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java index 0cfda7e2..5ec12cba 100644 --- a/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java +++ b/src/test/java/org/folio/rest/api/CirculationSettingsAPITest.java @@ -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 = diff --git a/src/test/java/org/folio/rest/api/LoansApiTest.java b/src/test/java/org/folio/rest/api/LoansApiTest.java index 94b3d7e7..5270b908 100644 --- a/src/test/java/org/folio/rest/api/LoansApiTest.java +++ b/src/test/java/org/folio/rest/api/LoansApiTest.java @@ -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, @@ -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())); } diff --git a/src/test/java/org/folio/rest/api/StorageTestSuite.java b/src/test/java/org/folio/rest/api/StorageTestSuite.java index ffe473bc..bf9dbb70 100644 --- a/src/test/java/org/folio/rest/api/StorageTestSuite.java +++ b/src/test/java/org/folio/rest/api/StorageTestSuite.java @@ -81,7 +81,8 @@ TlrFeatureToggleJobAPITest.class, ActualCostRecordAPITest.class, EventConsumerVerticleTest.class, - CheckOutLockAPITest.class + CheckOutLockAPITest.class, + CirculationSettingsAPITest.class }) public class StorageTestSuite { 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 b1aaabbc..7954a31f 100644 --- a/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java +++ b/src/test/java/org/folio/rest/support/builders/LoanRequestBuilder.java @@ -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(), @@ -58,6 +59,7 @@ public LoanRequestBuilder() { null, null, null, + null, null); } @@ -154,7 +156,9 @@ public static LoanRequestBuilder from(JsonObject example) { overdueFinePolicyId, lostItemPolicyId, claimedReturnedDate, - agedToLostDelayedBilling); + agedToLostDelayedBilling, + example.getBoolean("isDcb") + ); } @Override @@ -242,6 +246,10 @@ public JsonObject create() { request.put("agedToLostDelayedBilling", agedToLostDelayedBilling); } + if (isDcb != null) { + request.put("isDcb", isDcb); + } + return request; }