Search in sources :

Example 11 with CheckInByBarcodeRequestBuilder

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

the class RequestScheduledNoticesProcessingTests method uponAtHoldExpirationNoticeShouldBeDeletedWithoutSendingWhenItemIsMarkedAs.

@ParameterizedTest
@ValueSource(strings = { "In process", "In process (non-requestable)", "Intellectual item", "Long missing", "Missing", "Restricted", "Unavailable", "Unknown", "Withdrawn" })
void uponAtHoldExpirationNoticeShouldBeDeletedWithoutSendingWhenItemIsMarkedAs(String itemStatus) {
    setupNoticePolicyWithRequestNotice(new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withHoldShelfExpirationEvent().withUponAtTiming().sendInRealTime(true).create());
    IndividualResource request = requestsFixture.place(new RequestBuilder().page().forItem(item).withRequesterId(requester.getId()).withRequestDate(getZonedDateTime()).withStatus(OPEN_NOT_YET_FILLED).withPickupServicePoint(pickupServicePoint));
    checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(item).withItemBarcode(item.getBarcode()).at(pickupServicePoint));
    assertThat(requestsClient.getById(request.getId()).getJson(), isOpenAwaitingPickup());
    verifyNumberOfScheduledNotices(1);
    markItemAs(itemStatus, item.getId(), request.getId());
    scheduledNoticeProcessingClient.runRequestNoticesProcessing(atStartOfDay(getLocalDate().plusDays(31), UTC));
    verifyNumberOfScheduledNotices(0);
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Also used : CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with CheckInByBarcodeRequestBuilder

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

the class RequestScheduledNoticesProcessingTests method beforeHoldExpirationNoticeShouldBeSentAndDeletedWhenIsNotRecurring.

@Test
void beforeHoldExpirationNoticeShouldBeSentAndDeletedWhenIsNotRecurring() {
    JsonObject noticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withHoldShelfExpirationEvent().withBeforeTiming(Period.days(5)).sendInRealTime(true).create();
    setupNoticePolicyWithRequestNotice(noticeConfiguration);
    final LocalDate localDate = getLocalDate().plusMonths(3);
    final var requestExpiration = LocalDate.of(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
    IndividualResource request = requestsFixture.place(new RequestBuilder().page().forItem(item).withRequesterId(requester.getId()).withRequestDate(getZonedDateTime()).withStatus(OPEN_NOT_YET_FILLED).withPickupServicePoint(pickupServicePoint).withRequestExpiration(requestExpiration));
    CheckInByBarcodeRequestBuilder builder = new CheckInByBarcodeRequestBuilder().forItem(item).withItemBarcode(item.getBarcode()).at(pickupServicePoint);
    checkInFixture.checkInByBarcode(builder);
    verifyNumberOfScheduledNotices(1);
    scheduledNoticeProcessingClient.runRequestNoticesProcessing(atStartOfDay(getLocalDate().plusDays(28), UTC));
    verifyNumberOfSentNotices(1);
    assertThat(FakeModNotify.getFirstSentPatronNotice(), getTemplateContextMatcher(TEMPLATE_ID, requestsClient.get(request.getId())));
    verifyNumberOfScheduledNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 1);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Also used : CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) LocalDate(java.time.LocalDate) ClockUtil.getLocalDate(org.folio.circulation.support.utils.ClockUtil.getLocalDate) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with CheckInByBarcodeRequestBuilder

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

the class RequestScheduledNoticesProcessingTests method uponAtHoldExpirationNoticeShouldBeSentAndDeletedWhenHoldExpirationDateHasPassed.

@Test
@Disabled("notice is deleted once the request status is changed to 'Closed - Pickup expired'")
// TODO fix this test and make it useful again
void uponAtHoldExpirationNoticeShouldBeSentAndDeletedWhenHoldExpirationDateHasPassed() {
    JsonObject noticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withHoldShelfExpirationEvent().withUponAtTiming().sendInRealTime(true).create();
    setupNoticePolicyWithRequestNotice(noticeConfiguration);
    IndividualResource request = requestsFixture.place(new RequestBuilder().page().forItem(item).withRequesterId(requester.getId()).withRequestDate(getZonedDateTime()).withStatus(OPEN_NOT_YET_FILLED).withPickupServicePoint(pickupServicePoint));
    CheckInByBarcodeRequestBuilder builder = new CheckInByBarcodeRequestBuilder().forItem(item).withItemBarcode(item.getBarcode()).at(pickupServicePoint);
    checkInFixture.checkInByBarcode(builder);
    verifyNumberOfScheduledNotices(1);
    // close request
    requestsClient.replace(request.getId(), request.getJson().put("status", "Closed - Pickup expired"));
    scheduledNoticeProcessingClient.runRequestNoticesProcessing(atStartOfDay(getLocalDate().plusDays(31), UTC));
    verifyNumberOfScheduledNotices(0);
    verifyNumberOfSentNotices(1);
    verifyNumberOfPublishedEvents(NOTICE, 1);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Also used : CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Disabled(org.junit.jupiter.api.Disabled)

Example 14 with CheckInByBarcodeRequestBuilder

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

the class RequestScheduledNoticesProcessingTests method uponAtHoldExpirationNoticeShouldNotBeSentWhenHoldExpirationDateHasPassedAndItemCheckedOut.

@Test
void uponAtHoldExpirationNoticeShouldNotBeSentWhenHoldExpirationDateHasPassedAndItemCheckedOut() {
    JsonObject noticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withHoldShelfExpirationEvent().withUponAtTiming().sendInRealTime(true).create();
    setupNoticePolicyWithRequestNotice(noticeConfiguration);
    IndividualResource request = requestsFixture.place(new RequestBuilder().page().forItem(item).withRequesterId(requester.getId()).withRequestDate(getZonedDateTime()).withStatus(OPEN_NOT_YET_FILLED).withPickupServicePoint(pickupServicePoint));
    CheckInByBarcodeRequestBuilder builder = new CheckInByBarcodeRequestBuilder().forItem(item).withItemBarcode(item.getBarcode()).at(pickupServicePoint);
    checkInFixture.checkInByBarcode(builder);
    verifyNumberOfScheduledNotices(1);
    assertThat(FakeModNotify.getSentPatronNotices(), empty());
    checkOutFixture.checkOutByBarcode(item, requester);
    waitAtMost(1, SECONDS).until(() -> requestsClient.get(request.getId()).getJson().getString("status"), equalTo("Closed - Filled"));
    scheduledNoticeProcessingClient.runRequestNoticesProcessing(atStartOfDay(getLocalDate().plusDays(100), UTC));
    verifyNumberOfScheduledNotices(0);
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Also used : CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with CheckInByBarcodeRequestBuilder

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

the class RequestScheduledNoticesTests method holdShelfExpirationNoticeShouldBeScheduledOnCheckIn.

@Test
void holdShelfExpirationNoticeShouldBeScheduledOnCheckIn() {
    JsonObject requestNotice = new NoticeConfigurationBuilder().withTemplateId(templateId).withHoldShelfExpirationEvent().withUponAtTiming().sendInRealTime(true).create();
    NoticePolicyBuilder noticePolicyBuilder = new NoticePolicyBuilder().withName("request policy").withRequestNotices(Collections.singletonList(requestNotice));
    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);
    IndividualResource request = requestsFixture.place(requestBuilder);
    CheckInByBarcodeRequestBuilder checkInByBarcodeRequestBuilder = new CheckInByBarcodeRequestBuilder().forItem(item).withItemBarcode(item.getBarcode()).at(pickupServicePoint);
    checkInFixture.checkInByBarcode(checkInByBarcodeRequestBuilder);
    String holdShelfExpirationDate = requestsClient.get(request).getJson().getString(HOLD_SHELF_EXPIRATION_DATE);
    Awaitility.await().atMost(1, TimeUnit.SECONDS).until(scheduledNoticesClient::getAll, hasSize(1));
    List<JsonObject> scheduledNotices = scheduledNoticesClient.getAll();
    assertThat(scheduledNotices.size(), is(1));
    JsonObject scheduledNotice = scheduledNotices.get(0);
    JsonObject noticeConfig = scheduledNotice.getJsonObject("noticeConfig");
    assertThat(scheduledNotice.getString("requestId"), is(request.getId().toString()));
    assertThat(scheduledNotice.getString("triggeringEvent"), is("Hold expiration"));
    assertThat(scheduledNotice.getString("nextRunTime"), is(holdShelfExpirationDate));
    assertThat(noticeConfig.getString("timing"), is("Upon At"));
    assertThat(noticeConfig.getString("templateId"), is(templateId.toString()));
    assertThat(noticeConfig.getString("format"), is("Email"));
    assertThat(noticeConfig.getBoolean("sendInRealTime"), is(true));
}
Also used : 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) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Aggregations

CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)79 Test (org.junit.jupiter.api.Test)71 IndividualResource (api.support.http.IndividualResource)61 JsonObject (io.vertx.core.json.JsonObject)60 UUID (java.util.UUID)33 ZonedDateTime (java.time.ZonedDateTime)26 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)23 ItemResource (api.support.http.ItemResource)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Response (org.folio.circulation.support.http.client.Response)18 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)15 RequestBuilder (api.support.builders.RequestBuilder)14 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)11 FeeFineBuilder (api.support.builders.FeeFineBuilder)8 FeeFineOwnerBuilder (api.support.builders.FeeFineOwnerBuilder)8 LocalDate (java.time.LocalDate)7 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)5 UserResource (api.support.http.UserResource)3 JsonObjectMatcher (api.support.matchers.JsonObjectMatcher)3 HashMap (java.util.HashMap)3