Search in sources :

Example 1 with NoticeConfigurationBuilder

use of api.support.builders.NoticeConfigurationBuilder 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 2 with NoticeConfigurationBuilder

use of api.support.builders.NoticeConfigurationBuilder 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 3 with NoticeConfigurationBuilder

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

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

the class RequestScheduledNoticesProcessingTests method beforeRequestExpirationNoticeShouldBeSentAndDeletedWhenIsNotRecurring.

@Test
void beforeRequestExpirationNoticeShouldBeSentAndDeletedWhenIsNotRecurring() {
    JsonObject noticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withRequestExpirationEvent().withBeforeTiming(Period.days(5)).sendInRealTime(true).create();
    setupNoticePolicyWithRequestNotice(noticeConfiguration);
    final LocalDate localDate = getLocalDate().plusDays(4);
    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));
    verifyNumberOfScheduledNotices(1);
    scheduledNoticeProcessingClient.runRequestNoticesProcessing();
    verifyNumberOfSentNotices(1);
    assertThat(FakeModNotify.getFirstSentPatronNotice(), getTemplateContextMatcher(TEMPLATE_ID, request));
    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) 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 5 with NoticeConfigurationBuilder

use of api.support.builders.NoticeConfigurationBuilder 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)

Aggregations

NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)75 JsonObject (io.vertx.core.json.JsonObject)66 Test (org.junit.jupiter.api.Test)66 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)64 IndividualResource (api.support.http.IndividualResource)57 ZonedDateTime (java.time.ZonedDateTime)52 UUID (java.util.UUID)41 RequestBuilder (api.support.builders.RequestBuilder)37 ItemResource (api.support.http.ItemResource)37 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)27 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)21 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)21 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)12 ItemBuilder (api.support.builders.ItemBuilder)11 Period (org.folio.circulation.domain.policy.Period)11 Matcher (org.hamcrest.Matcher)11 HashMap (java.util.HashMap)9 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)8 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)8 lombok.val (lombok.val)8