Search in sources :

Example 11 with RequestBuilder

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

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

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

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);
}
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 15 with RequestBuilder

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

RequestBuilder (api.support.builders.RequestBuilder)269 Test (org.junit.jupiter.api.Test)244 IndividualResource (api.support.http.IndividualResource)212 UUID (java.util.UUID)134 JsonObject (io.vertx.core.json.JsonObject)127 Response (org.folio.circulation.support.http.client.Response)124 ItemResource (api.support.http.ItemResource)117 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)113 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)89 ZonedDateTime (java.time.ZonedDateTime)77 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)53 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)43 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)37 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)34 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)28 ItemBuilder (api.support.builders.ItemBuilder)19 lombok.val (lombok.val)17 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)10 MultipleJsonRecords (api.support.MultipleJsonRecords)9 Address (api.support.builders.Address)9