use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class OverrideRenewalTest method shouldUseOverrideDateWhenLoanIsNotLoanable.
@Test
void shouldUseOverrideDateWhenLoanIsNotLoanable() {
final ZonedDateTime overrideDate = ClockUtil.getZonedDateTime().plusMonths(1);
final JsonObject loanPolicyJson = new LoanPolicyBuilder().withLoanable(false).create();
final Result<Loan> renewedLoan = renew(LoanPolicy.from(loanPolicyJson), overrideDate);
assertDueDate(overrideDate, renewedLoan);
assertEquals(CHECKED_OUT, renewedLoan.value().getItem().getStatus());
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class OverrideRenewalTest method nonLoanableAgedToLostItemShouldBeProperlyRenewed.
@Test
void nonLoanableAgedToLostItemShouldBeProperlyRenewed() {
final ZonedDateTime newDueDate = ClockUtil.getZonedDateTime().plusWeeks(1);
final ZonedDateTime ageToLostDate = ClockUtil.getZonedDateTime();
final LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().withLoanable(false).create());
final Loan loan = Loan.from(new JsonObject()).withItem(createCheckedOutItem()).withLoanPolicy(loanPolicy);
loan.ageOverdueItemToLost(ageToLostDate).setAgedToLostDelayedBilling(false, ageToLostDate.plusDays(1));
final Result<Loan> renewedLoan = renew(loan, newDueDate);
assertDueDate(newDueDate, renewedLoan);
assertEquals(CHECKED_OUT, renewedLoan.value().getItem().getStatus());
assertThat(renewedLoan.value().asJson(), allOf(hasNoJsonPath("agedToLostDelayedBilling.lostItemHasBeenBilled"), hasNoJsonPath("agedToLostDelayedBilling.dateLostItemShouldBeBilled")));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class OverrideRenewalTest method overrideDateIsRequiredWhenLoanIsNotLoanable.
@Test
void overrideDateIsRequiredWhenLoanIsNotLoanable() {
final JsonObject loanPolicyJson = new LoanPolicyBuilder().withLoanable(false).create();
final Result<Loan> renewedLoan = renew(LoanPolicy.from(loanPolicyJson), null);
assertThat(renewedLoan, hasValidationError(hasMessage(OVERRIDE_DUE_DATE_MUST_BE_SPECIFIED_ERROR)));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class RegularRenewalTest method cannotRenewWhenHoldRequestedAndFixedPolicyHasAlternativeRenewPeriod.
@Test
void cannotRenewWhenHoldRequestedAndFixedPolicyHasAlternativeRenewPeriod() {
final var request = new RequestBuilder().hold().asDomainObject();
final var loanPolicy = new LoanPolicyBuilder().fixed(UUID.randomUUID()).withHolds(null, true, days(1)).asDomainObject();
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loanPolicy, request, errorHandler);
assertTrue(matchErrorReason(errorHandler, ALTERNATIVE_RENEWAL_PERIOD_FOR_HOLDS_IS_SPECIFIED));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class RegularRenewalTest method cannotRenewWhenHoldRequestedAndFixedPolicyHasRenewPeriod.
@Test
void cannotRenewWhenHoldRequestedAndFixedPolicyHasRenewPeriod() {
final var request = new RequestBuilder().hold().asDomainObject();
final var loanPolicy = new LoanPolicyBuilder().fixed(UUID.randomUUID()).renewWith(days(10)).withHolds(null, true, null).asDomainObject();
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loanPolicy, request, errorHandler);
assertTrue(matchErrorReason(errorHandler, POLICY_HAS_FIXED_PROFILE_BUT_RENEWAL_PERIOD_IS_SPECIFIED));
}
Aggregations