Search in sources :

Example 1 with RequestBuilder

use of api.support.builders.RequestBuilder 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));
}
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 2 with RequestBuilder

use of api.support.builders.RequestBuilder 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));
}
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 3 with RequestBuilder

use of api.support.builders.RequestBuilder 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 4 with RequestBuilder

use of api.support.builders.RequestBuilder in project mod-circulation by folio-org.

the class JsonSchemaValidationTest method canValidateSchemaWithReferences.

@Test
void canValidateSchemaWithReferences() throws IOException {
    final JsonSchemaValidator validator = JsonSchemaValidator.fromResource("/request.json");
    final JsonObject request = new RequestBuilder().hold().itemRequestLevel().withItemId(UUID.randomUUID()).withInstanceId(UUID.randomUUID()).withRequesterId(UUID.randomUUID()).fulfilToHoldShelf(UUID.randomUUID()).withRequestDate(ClockUtil.getZonedDateTime()).create();
    assertThat(validator.validate(request.encode()), succeeded());
}
Also used : RequestBuilder(api.support.builders.RequestBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.jupiter.api.Test)

Example 5 with RequestBuilder

use of api.support.builders.RequestBuilder in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method titleLevelRequestIsIgnoredWhenTlrFeatureIsNotEnabled.

@ParameterizedTest
@EnumSource(value = TlrFeatureStatus.class, names = { "DISABLED", "NOT_CONFIGURED" })
void titleLevelRequestIsIgnoredWhenTlrFeatureIsNotEnabled(TlrFeatureStatus tlrFeatureStatus) {
    configurationsFixture.enableTlrFeature();
    ItemResource item = itemsFixture.basedUponNod();
    UserResource borrower = usersFixture.steve();
    UserResource requester = usersFixture.james();
    requestsClient.create(new RequestBuilder().page().titleRequestLevel().withNoItemId().withNoHoldingsRecordId().withInstanceId(item.getInstanceId()).withPickupServicePointId(servicePointsFixture.cd1().getId()).withRequesterId(requester.getId()));
    reconfigureTlrFeature(tlrFeatureStatus);
    checkOutFixture.checkOutByBarcode(item, borrower);
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) UserResource(api.support.http.UserResource) ItemResource(api.support.http.ItemResource) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RequestBuilder (api.support.builders.RequestBuilder)269 Test (org.junit.jupiter.api.Test)244 IndividualResource (api.support.http.IndividualResource)212 UUID (java.util.UUID)134 JsonObject (io.vertx.core.json.JsonObject)127 Response (org.folio.circulation.support.http.client.Response)124 ItemResource (api.support.http.ItemResource)117 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)113 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)89 ZonedDateTime (java.time.ZonedDateTime)77 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)53 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)43 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)37 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)34 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)28 ItemBuilder (api.support.builders.ItemBuilder)19 lombok.val (lombok.val)17 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)10 MultipleJsonRecords (api.support.MultipleJsonRecords)9 Address (api.support.builders.Address)9