use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenLoanDateIsBeforeOnlyScheduleAvailable.
@Test
void shouldFailWhenLoanDateIsBeforeOnlyScheduleAvailable() {
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).withName("Example Fixed Schedule Loan Policy").create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeYear(2018)).create());
Loan loan = existingLoan(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2017, 12, 30, 14, 32, 21, 0, UTC);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), errorHandler);
assertEquals(1, errorHandler.getErrors().size());
assertTrue(matchErrorReason(errorHandler, EXPECTED_REASON_DATE_FALLS_OUTSIDE_DATE_RANGES));
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenLoanDateIsAfterAllSchedules.
@Test
void shouldFailWhenLoanDateIsAfterAllSchedules() {
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).withName("Example Fixed Schedule Loan Policy").create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 2)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 3)).create());
Loan loan = existingLoan(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2018, 4, 1, 6, 34, 21, 0, UTC);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), errorHandler);
assertTrue(matchErrorReason(errorHandler, EXPECTED_REASON_DATE_FALLS_OUTSIDE_DATE_RANGES));
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldUseMiddleScheduleAvailableWhenLoanDateFits.
@Test
void shouldUseMiddleScheduleAvailableWhenLoanDateFits() {
final FixedDueDateSchedule expectedSchedule = FixedDueDateSchedule.wholeMonth(2018, 2);
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(expectedSchedule).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 3)).create());
Loan loan = existingLoan(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2018, 2, 27, 16, 23, 43, 0, UTC);
Result<Loan> result = renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), new OverridingErrorHandler(null));
assertThat(result.value().getDueDate(), is(expectedSchedule.due));
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldUseOnlyScheduleAvailableWhenLoanDateFits.
@Test
void shouldUseOnlyScheduleAvailableWhenLoanDateFits() {
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeYear(2018)).create());
Loan loan = existingLoan(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2018, 3, 14, 11, 14, 54, 0, UTC);
String requestId = UUID.randomUUID().toString();
RequestQueue requestQueue = creteRequestQueue(requestId, RequestType.PAGE);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
Result<Loan> result = renew(loan, renewalDate, requestQueue, errorHandler);
final ZonedDateTime expectedDate = atStartOfDay(LocalDate.of(2018, 12, 31), UTC).plusDays(1).minusSeconds(1);
assertThat(result.value().getDueDate(), is(expectedDate));
}
use of org.folio.circulation.domain.Loan in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenLoanDateIsBeforeAllSchedules.
@Test
void shouldFailWhenLoanDateIsBeforeAllSchedules() {
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).withName("Example Fixed Schedule Loan Policy").create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 2)).addSchedule(FixedDueDateSchedule.wholeMonth(2018, 3)).create());
Loan loan = existingLoan(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2017, 12, 30, 14, 32, 21, 0, UTC);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), errorHandler);
assertEquals(1, errorHandler.getErrors().size());
assertTrue(matchErrorReason(errorHandler, EXPECTED_REASON_DATE_FALLS_OUTSIDE_DATE_RANGES));
}
Aggregations