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