Search in sources :

Example 6 with LoanPolicyBuilder

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));
}
Also used : CirculationErrorHandler(org.folio.circulation.resources.handlers.error.CirculationErrorHandler) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with LoanPolicyBuilder

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));
}
Also used : RequestBuilder(api.support.builders.RequestBuilder) CirculationErrorHandler(org.folio.circulation.resources.handlers.error.CirculationErrorHandler) OverridingErrorHandler(org.folio.circulation.resources.handlers.error.OverridingErrorHandler) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with LoanPolicyBuilder

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))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 9 with LoanPolicyBuilder

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))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) UserResource(api.support.http.UserResource) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 10 with LoanPolicyBuilder

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();
}
Also used : LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder)

Aggregations

LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)199 Test (org.junit.jupiter.api.Test)173 ZonedDateTime (java.time.ZonedDateTime)135 IndividualResource (api.support.http.IndividualResource)97 JsonObject (io.vertx.core.json.JsonObject)87 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)79 Loan (org.folio.circulation.domain.Loan)70 FixedDueDateSchedulesBuilder (api.support.builders.FixedDueDateSchedulesBuilder)64 UUID (java.util.UUID)63 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)57 OverridingErrorHandler (org.folio.circulation.resources.handlers.error.OverridingErrorHandler)50 CirculationErrorHandler (org.folio.circulation.resources.handlers.error.CirculationErrorHandler)39 RequestQueue (org.folio.circulation.domain.RequestQueue)37 RequestBuilder (api.support.builders.RequestBuilder)34 Response (org.folio.circulation.support.http.client.Response)32 ItemResource (api.support.http.ItemResource)25 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)23 LoanBuilder (api.support.builders.LoanBuilder)18 FixedDueDateSchedule (api.support.builders.FixedDueDateSchedule)16 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)16