use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenRenewalWouldMeanEarlierDueDate.
@Test
void shouldFailWhenRenewalWouldMeanEarlierDueDate() {
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().fixed(UUID.randomUUID()).withName("Example Fixed Schedule Loan Policy").create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeMonth(2018, 1)).create());
Loan loan = new LoanBuilder().open().withLoanDate(ZonedDateTime.of(2018, 1, 20, 13, 45, 21, 0, UTC)).withDueDate(ZonedDateTime.of(2018, 2, 28, 23, 59, 59, 0, UTC)).asDomainObject().withLoanPolicy(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2018, 1, 3, 8, 12, 32, 0, UTC);
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, renewalDate, new RequestQueue(Collections.emptyList()), errorHandler);
assertTrue(matchErrorReason(errorHandler, RENEWAL_WOULD_NOT_CHANGE_THE_DUE_DATE));
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenLoanDateIsAfterOnlyScheduleAvailable.
@Test
void shouldFailWhenLoanDateIsAfterOnlyScheduleAvailable() {
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(2019, 1, 1, 8, 10, 45, 0, UTC);
RequestQueue requestQueue = new RequestQueue(Collections.emptyList());
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loan, renewalDate, requestQueue, errorHandler);
assertEquals(1, errorHandler.getErrors().size());
assertTrue(matchErrorReason(errorHandler, EXPECTED_REASON_DATE_FALLS_OUTSIDE_DATE_RANGES));
}
use of org.folio.circulation.domain.RequestQueue in project mod-circulation by folio-org.
the class FixedLoanPolicyRenewalDueDateCalculationTests method shouldFailWhenLoanDateIsInBetweenSchedules.
@Test
void shouldFailWhenLoanDateIsInBetweenSchedules() {
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, 3)).create());
Loan loan = existingLoan(loanPolicy);
ZonedDateTime renewalDate = ZonedDateTime.of(2018, 2, 18, 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.RequestQueue 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.RequestQueue 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));
}
Aggregations