use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class LoanDueDatesAfterRecallTests method secondRecallRequestWithMGDTruncationInPlaceDoesNotChangeDueDate.
@Test
void secondRecallRequestWithMGDTruncationInPlaceDoesNotChangeDueDate() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requestServicePoint = servicePointsFixture.cd1();
final IndividualResource steve = usersFixture.steve();
final IndividualResource jessica = usersFixture.jessica();
final IndividualResource charlotte = usersFixture.charlotte();
final LoanPolicyBuilder canCirculateRollingPolicy = new LoanPolicyBuilder().withName("Can Circulate Rolling With Recalls").withDescription("Can circulate item With Recalls").rolling(Period.weeks(3)).unlimitedRenewals().renewFromSystemDate().withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(2)).withRecallsRecallReturnInterval(Period.weeks(1));
setFallbackPolicies(canCirculateRollingPolicy);
final IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, steve, getZonedDateTime());
final String originalDueDate = loan.getJson().getString("dueDate");
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, jessica, getZonedDateTime(), requestServicePoint.getId(), "Recall");
JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
final String recalledDueDate = storedLoan.getString("dueDate");
assertThat("due date after recall should not be the original date", recalledDueDate, not(originalDueDate));
final String expectedDueDate = formatDateTime(getZonedDateTime().plusWeeks(2));
assertThat("due date after recall should be in 2 weeks", storedLoan.getString("dueDate"), is(expectedDueDate));
setClock(Clock.offset(getClock(), Duration.ofDays(7)));
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, charlotte, getZonedDateTime(), requestServicePoint.getId(), "Recall");
storedLoan = loansStorageClient.getById(loan.getId()).getJson();
assertThat("second recall should not change the due date (2 weeks)", storedLoan.getString("dueDate"), is(recalledDueDate));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class LoanDueDatesAfterRecallTests method initialLoanDueDateOnCreateWithPrexistingRequests.
@Test
void initialLoanDueDateOnCreateWithPrexistingRequests() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requestServicePoint = servicePointsFixture.cd1();
final IndividualResource steve = usersFixture.steve();
final IndividualResource jessica = usersFixture.jessica();
final IndividualResource charlotte = usersFixture.charlotte();
final LoanPolicyBuilder canCirculateRollingPolicy = new LoanPolicyBuilder().withName("Can Circulate Rolling With Recalls").withDescription("Can circulate item With Recalls").rolling(Period.weeks(3)).unlimitedRenewals().renewFromSystemDate().withClosedLibraryDueDateManagement(KEEP_THE_CURRENT_DUE_DATE.getValue()).withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(2)).withRecallsRecallReturnInterval(Period.months(2));
setFallbackPolicies(canCirculateRollingPolicy);
checkOutFixture.checkOutByBarcode(smallAngryPlanet, charlotte, getZonedDateTime());
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, steve, getZonedDateTime(), requestServicePoint.getId(), "Recall");
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, jessica, getZonedDateTime(), requestServicePoint.getId(), "Recall");
checkInFixture.checkInByBarcode(smallAngryPlanet);
final IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, steve, getZonedDateTime());
final JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
final String expectedDueDate = formatDateTime(ZonedDateTime.of(getZonedDateTime().plusMonths(2).toLocalDate(), LocalTime.MIDNIGHT.minusSeconds(1), getZoneId()));
assertThat("due date should be in 2 months (recall return interval)", storedLoan.getString("dueDate"), is(expectedDueDate));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class LoanDueDatesAfterRecallTests method pagedItemRecalledThenLoanedAndNextRecallDoesNotChangeDueDate.
@Test
void pagedItemRecalledThenLoanedAndNextRecallDoesNotChangeDueDate() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requestServicePoint = servicePointsFixture.cd1();
final IndividualResource jessica = usersFixture.jessica();
final IndividualResource charlotte = usersFixture.charlotte();
final IndividualResource james = usersFixture.james();
final LoanPolicyBuilder canCirculateRollingPolicy = new LoanPolicyBuilder().withName("Can Circulate Rolling With Recalls").withDescription("Can circulate item With Recalls").rolling(Period.weeks(3)).unlimitedRenewals().renewFromSystemDate().withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(2)).withRecallsRecallReturnInterval(Period.weeks(1));
setFallbackPolicies(canCirculateRollingPolicy);
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, jessica, getZonedDateTime(), requestServicePoint.getId(), "Page");
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, james, getZonedDateTime(), requestServicePoint.getId(), "Recall");
final IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, jessica, getZonedDateTime());
// Recalled is applied when loaned, so the due date should be 2 weeks, not 3 weeks
final String expectedDueDate = formatDateTime(getZonedDateTime().plusWeeks(2));
JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
final String recalledDueDate = storedLoan.getString("dueDate");
assertThat("due date after recall should be 2 weeks", recalledDueDate, is(expectedDueDate));
setClock(Clock.offset(getClock(), Duration.ofDays(1)));
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, charlotte, getZonedDateTime(), requestServicePoint.getId(), "Recall");
storedLoan = loansStorageClient.getById(loan.getId()).getJson();
assertThat("second recall should not change the due date", storedLoan.getString("dueDate"), is(recalledDueDate));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class LoanDueDatesAfterRecallTests method recallRequestWithMGDAndRDValuesChangesDueDateToMGD.
@Test
void recallRequestWithMGDAndRDValuesChangesDueDateToMGD() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requestServicePoint = servicePointsFixture.cd1();
final IndividualResource steve = usersFixture.steve();
final IndividualResource jessica = usersFixture.jessica();
final LoanPolicyBuilder canCirculateRollingPolicy = new LoanPolicyBuilder().withName("Can Circulate Rolling With Recalls").withDescription("Can circulate item With Recalls").rolling(Period.weeks(3)).unlimitedRenewals().renewFromSystemDate().withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(2)).withRecallsRecallReturnInterval(Period.weeks(1));
setFallbackPolicies(canCirculateRollingPolicy);
// We use the loan date to calculate the MGD
final ZonedDateTime loanDate = getZonedDateTime();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, steve, loanDate);
final String originalDueDate = loan.getJson().getString("dueDate");
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, jessica, getZonedDateTime(), requestServicePoint.getId(), "Recall");
final JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
assertThat("due date should not be the original due date", storedLoan.getString("dueDate"), not(originalDueDate));
final String expectedDueDate = formatDateTime(loanDate.plusWeeks(2));
assertThat("due date should be in 2 weeks (minumum guaranteed loan period)", storedLoan.getString("dueDate"), is(expectedDueDate));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class LoanDueDatesAfterRecallTests method secondRecallRequestWithRDTruncationInPlaceAndLoanOverdueDoesNotChangeDueDate.
@Test
void secondRecallRequestWithRDTruncationInPlaceAndLoanOverdueDoesNotChangeDueDate() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requestServicePoint = servicePointsFixture.cd1();
final IndividualResource steve = usersFixture.steve();
final IndividualResource jessica = usersFixture.jessica();
final IndividualResource charlotte = usersFixture.charlotte();
final LoanPolicyBuilder canCirculateRollingPolicy = new LoanPolicyBuilder().withName("Can Circulate Rolling With Recalls").withDescription("Can circulate item With Recalls").rolling(Period.weeks(3)).unlimitedRenewals().renewFromSystemDate().withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(2)).withRecallsRecallReturnInterval(Period.months(2));
setFallbackPolicies(canCirculateRollingPolicy);
final IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, steve, getZonedDateTime());
final String originalDueDate = loan.getJson().getString("dueDate");
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, jessica, getZonedDateTime(), requestServicePoint.getId(), "Recall");
JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
final String recalledDueDate = storedLoan.getString("dueDate");
assertThat("due date after recall should not be the original date", recalledDueDate, not(originalDueDate));
final String expectedDueDate = formatDateTime(getZonedDateTime().plusMonths(2));
assertThat("due date after recall should be in 2 months", storedLoan.getString("dueDate"), is(expectedDueDate));
// Move the fixed clock so that the loan is now overdue
setClock(Clock.offset(getClock(), Duration.ofDays(70)));
requestsFixture.placeItemLevelHoldShelfRequest(smallAngryPlanet, charlotte, getZonedDateTime(), requestServicePoint.getId(), "Recall");
storedLoan = loansStorageClient.getById(loan.getId()).getJson();
assertThat("second recall should not change the due date (2 months)", storedLoan.getString("dueDate"), is(recalledDueDate));
}
Aggregations