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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations