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