Search in sources :

Example 1 with OPEN_NOT_YET_FILLED

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

the class RequestScheduledNoticesTests method requestExpirationAndHoldShelfExpirationNoticesAreCreatedWhenPickupReminderIsFirstInPolicy.

@Test
void requestExpirationAndHoldShelfExpirationNoticesAreCreatedWhenPickupReminderIsFirstInPolicy() {
    JsonObject pickupReminder = new NoticeConfigurationBuilder().withTemplateId(templateId).withAvailableEvent().sendInRealTime(true).create();
    JsonObject holdShelfExpirationNotice = new NoticeConfigurationBuilder().withTemplateId(templateId).withHoldShelfExpirationEvent().withUponAtTiming().sendInRealTime(true).create();
    JsonObject requestExpirationNotice = new NoticeConfigurationBuilder().withTemplateId(templateId).withRequestExpirationEvent().withUponAtTiming().sendInRealTime(true).create();
    NoticePolicyBuilder noticePolicyBuilder = new NoticePolicyBuilder().withName("request policy").withRequestNotices(Arrays.asList(pickupReminder, holdShelfExpirationNotice, requestExpirationNotice));
    useDefaultRollingPoliciesAndOnlyAllowPageRequests(noticePolicyBuilder);
    final var requestExpiration = ClockUtil.getZonedDateTime().toLocalDate().plusMonths(3);
    RequestBuilder requestBuilder = new RequestBuilder().page().forItem(item).withRequesterId(requester.getId()).withRequestDate(ClockUtil.getZonedDateTime()).withStatus(OPEN_NOT_YET_FILLED).withPickupServicePoint(pickupServicePoint).withRequestExpiration(requestExpiration);
    requestsFixture.place(requestBuilder);
    CheckInByBarcodeRequestBuilder checkInByBarcodeRequestBuilder = new CheckInByBarcodeRequestBuilder().forItem(item).withItemBarcode(item.getBarcode()).at(pickupServicePoint);
    checkInFixture.checkInByBarcode(checkInByBarcodeRequestBuilder);
    Awaitility.await().atMost(1, TimeUnit.SECONDS).until(scheduledNoticesClient::getAll, hasSize(2));
    List<JsonObject> scheduledNotices = scheduledNoticesClient.getAll();
    assertThat(scheduledNotices.size(), is(2));
    List<String> triggeringEvents = scheduledNotices.stream().map(n -> n.getString("triggeringEvent")).collect(Collectors.toList());
    assertThat(triggeringEvents, containsInAnyOrder("Request expiration", "Hold expiration"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) APITests(api.support.APITests) RequestBuilder(api.support.builders.RequestBuilder) ItemBuilder(api.support.builders.ItemBuilder) IndividualResource(api.support.http.IndividualResource) Period(org.folio.circulation.domain.policy.Period) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) HOLD_SHELF_EXPIRATION_DATE(org.folio.circulation.domain.representations.RequestProperties.HOLD_SHELF_EXPIRATION_DATE) TextDateTimeMatcher.isEquivalentTo(api.support.matchers.TextDateTimeMatcher.isEquivalentTo) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ItemExamples(api.support.fixtures.ItemExamples) JsonObject(io.vertx.core.json.JsonObject) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DateTimeUtil.atEndOfDay(org.folio.circulation.support.utils.DateTimeUtil.atEndOfDay) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) HoldingBuilder(api.support.builders.HoldingBuilder) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) List(java.util.List) OPEN_NOT_YET_FILLED(api.support.builders.RequestBuilder.OPEN_NOT_YET_FILLED) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) ClockUtil(org.folio.circulation.support.utils.ClockUtil) UTC(java.time.ZoneOffset.UTC) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) Awaitility(org.awaitility.Awaitility) RequestBuilder(api.support.builders.RequestBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

APITests (api.support.APITests)1 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)1 HoldingBuilder (api.support.builders.HoldingBuilder)1 ItemBuilder (api.support.builders.ItemBuilder)1 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)1 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)1 RequestBuilder (api.support.builders.RequestBuilder)1 OPEN_NOT_YET_FILLED (api.support.builders.RequestBuilder.OPEN_NOT_YET_FILLED)1 ItemExamples (api.support.fixtures.ItemExamples)1 IndividualResource (api.support.http.IndividualResource)1 ItemResource (api.support.http.ItemResource)1 TextDateTimeMatcher.isEquivalentTo (api.support.matchers.TextDateTimeMatcher.isEquivalentTo)1 JsonObject (io.vertx.core.json.JsonObject)1 UTC (java.time.ZoneOffset.UTC)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 UUID (java.util.UUID)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1