use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class RegularRenewalTest method shouldNotAttemptToCalculateDueDateWhenPolicyIsNotRenewable.
@Test
void shouldNotAttemptToCalculateDueDateWhenPolicyIsNotRenewable() {
final var loanPolicy = spy(new LoanPolicyBuilder().rolling(days(1)).notRenewable().asDomainObject());
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loanPolicy, errorHandler);
assertTrue(matchErrorReason(errorHandler, LOAN_IS_NOT_RENEWABLE));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class RegularRenewalTest method cannotRenewWhenHoldRequestIsNotRenewable.
@Test
void cannotRenewWhenHoldRequestIsNotRenewable() {
final var request = new RequestBuilder().hold().asDomainObject();
final var loanPolicy = new LoanPolicyBuilder().withHolds(null, false, null).asDomainObject();
CirculationErrorHandler errorHandler = new OverridingErrorHandler(null);
renew(loanPolicy, request, errorHandler);
assertTrue(matchErrorReason(errorHandler, ITEMS_CANNOT_BE_RENEWED_ACTIVE_PENDING_HOLD_REQUEST));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotCheckOutWhenItemIsNotLoanable.
@Test
void cannotCheckOutWhenItemIsNotLoanable() {
IndividualResource notLoanablePolicy = loanPoliciesFixture.create(new LoanPolicyBuilder().withName("Not Loanable Policy").withLoanable(false));
useFallbackPolicies(notLoanablePolicy.getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.inactiveNotice().getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
ItemResource nod = itemsFixture.basedUponNod();
IndividualResource steve = usersFixture.steve();
Response response = checkOutFixture.attemptCheckOutByBarcode(nod, steve);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Item is not loanable"), hasItemBarcodeParameter(nod), hasLoanPolicyParameters(notLoanablePolicy))));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method failedCheckOutWithMultipleValidationErrors.
@Test
void failedCheckOutWithMultipleValidationErrors() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final UserResource steve = usersFixture.steve();
loanPoliciesFixture.create(new LoanPolicyBuilder().withId(UUID.randomUUID()).withName("Example loan policy").withLoanable(true));
checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(smallAngryPlanet).to(steve).on(getZonedDateTime()).at(UUID.randomUUID()));
usersFixture.remove(steve);
final Response secondCheckoutResponse = checkOutFixture.attemptCheckOutByBarcode(smallAngryPlanet, steve);
assertThat(secondCheckoutResponse.getJson(), hasErrorWith(allOf(hasMessage("Could not find user with matching barcode"), hasUserBarcodeParameter(steve))));
assertThat(secondCheckoutResponse.getJson(), hasErrorWith(allOf(hasMessage("Item is already checked out"), hasItemBarcodeParameter(smallAngryPlanet))));
assertThat(secondCheckoutResponse.getJson(), hasErrorWith(allOf(hasMessage("Cannot check out item that already has an open loan"), hasItemBarcodeParameter(smallAngryPlanet))));
}
use of api.support.builders.LoanPolicyBuilder in project mod-circulation by folio-org.
the class CheckOutCalculateDueDateTests method useFixedPolicy.
private void useFixedPolicy(UUID fixedDueDateScheduleId, DueDateManagement dueDateManagement) {
LoanPolicyBuilder loanPolicy = new LoanPolicyBuilder().withName("MOVE_TO_THE_END_OF_THE_PREVIOUS_OPEN_DAY: FIXED").withDescription("New LoanPolicy").fixed(fixedDueDateScheduleId).withClosedLibraryDueDateManagement(dueDateManagement.getValue()).renewFromCurrentDueDate();
use(loanPolicy);
loanPolicy.create();
}
Aggregations