Search in sources :

Example 1 with HoldingBuilder

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

the class RequestScheduledNoticesTests method beforeEach.

@BeforeEach
public void beforeEach() {
    ItemBuilder itemBuilder = ItemExamples.basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId());
    HoldingBuilder holdingBuilder = itemsFixture.applyCallNumberHoldings("CN", "Prefix", "Suffix", Collections.singletonList("CopyNumbers"));
    item = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, holdingBuilder);
    requester = usersFixture.steve();
    pickupServicePoint = servicePointsFixture.cd1();
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) HoldingBuilder(api.support.builders.HoldingBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with HoldingBuilder

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

the class RequestsAPICreationTests method holdRequestNoticeIsSentWhenPolicyDefinesHoldRequestNoticeConfiguration.

@Test
void holdRequestNoticeIsSentWhenPolicyDefinesHoldRequestNoticeConfiguration() {
    UUID holdConfirmationTemplateId = UUID.randomUUID();
    JsonObject holdConfirmationConfiguration = new NoticeConfigurationBuilder().withTemplateId(holdConfirmationTemplateId).withEventType(HOLD_REQUEST_EVENT).create();
    JsonObject recallConfirmationConfiguration = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withEventType(RECALL_REQUEST_EVENT).create();
    NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with hold notice").withLoanNotices(Arrays.asList(holdConfirmationConfiguration, recallConfirmationConfiguration));
    useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.create(noticePolicy).getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
    UUID id = UUID.randomUUID();
    UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    ItemBuilder itemBuilder = ItemExamples.basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId());
    HoldingBuilder holdingBuilder = itemsFixture.applyCallNumberHoldings("CN", "Prefix", "Suffix", Collections.singletonList("CopyNumbers"));
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, holdingBuilder);
    IndividualResource requester = usersFixture.steve();
    ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    IndividualResource request = requestsFixture.place(new RequestBuilder().withId(id).open().hold().forItem(item).by(requester).withRequestDate(requestDate).fulfilToHoldShelf().withRequestExpiration(LocalDate.of(2017, 7, 30)).withHoldShelfExpiration(LocalDate.of(2017, 8, 31)).withPickupServicePointId(pickupServicePointId).withTags(new RequestBuilder.Tags(asList("new", "important"))));
    verifyNumberOfSentNotices(1);
    verifyNumberOfPublishedEvents(NOTICE, 1);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
    Map<String, Matcher<String>> noticeContextMatchers = new HashMap<>();
    noticeContextMatchers.putAll(TemplateContextMatchers.getUserContextMatchers(requester));
    noticeContextMatchers.putAll(TemplateContextMatchers.getItemContextMatchers(item, true));
    noticeContextMatchers.putAll(TemplateContextMatchers.getRequestContextMatchers(request));
    assertThat(FakeModNotify.getSentPatronNotices(), hasItems(hasEmailNoticeProperties(requester.getId(), holdConfirmationTemplateId, noticeContextMatchers)));
}
Also used : MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) Matcher(org.hamcrest.Matcher) HashMap(java.util.HashMap) JsonObject(io.vertx.core.json.JsonObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Matchers.emptyString(org.hamcrest.Matchers.emptyString) HoldingBuilder(api.support.builders.HoldingBuilder) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ItemBuilder(api.support.builders.ItemBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) UUID(java.util.UUID) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with HoldingBuilder

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

the class DueDateScheduledNoticesProcessingTests method beforeEach.

@BeforeEach
public void beforeEach() {
    ItemBuilder itemBuilder = basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId());
    HoldingBuilder holdingBuilder = itemsFixture.applyCallNumberHoldings("CN", "Prefix", "Suffix", Collections.singletonList("CopyNumbers"));
    item = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, holdingBuilder);
    borrower = usersFixture.steve();
    templateFixture.createDummyNoticeTemplate(BEFORE_TEMPLATE_ID);
    templateFixture.createDummyNoticeTemplate(BEFORE_RECURRING_TEMPLATE_ID);
    templateFixture.createDummyNoticeTemplate(UPON_AT_TEMPLATE_ID);
    templateFixture.createDummyNoticeTemplate(AFTER_TEMPLATE_ID);
    templateFixture.createDummyNoticeTemplate(AFTER_RECURRING_TEMPLATE_ID);
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) HoldingBuilder(api.support.builders.HoldingBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with HoldingBuilder

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

the class RequestsAPICreationTests method holdRequestNoticeIsNotSentWhenPatronNoticeRequestFails.

@Test
void holdRequestNoticeIsNotSentWhenPatronNoticeRequestFails() {
    UUID holdConfirmationTemplateId = UUID.randomUUID();
    JsonObject holdConfirmationConfiguration = new NoticeConfigurationBuilder().withTemplateId(holdConfirmationTemplateId).withEventType(HOLD_REQUEST_EVENT).create();
    JsonObject recallConfirmationConfiguration = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withEventType(RECALL_REQUEST_EVENT).create();
    NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with hold notice").withLoanNotices(Arrays.asList(holdConfirmationConfiguration, recallConfirmationConfiguration));
    useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.create(noticePolicy).getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
    UUID id = UUID.randomUUID();
    UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    ItemBuilder itemBuilder = ItemExamples.basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId());
    HoldingBuilder holdingBuilder = itemsFixture.applyCallNumberHoldings("CN", "Prefix", "Suffix", Collections.singletonList("CopyNumbers"));
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, holdingBuilder);
    IndividualResource requester = usersFixture.steve();
    ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
    checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    FakeModNotify.setFailPatronNoticesWithBadRequest(true);
    requestsFixture.place(new RequestBuilder().withId(id).open().hold().forItem(item).by(requester).withRequestDate(requestDate).fulfilToHoldShelf().withRequestExpiration(LocalDate.of(2017, 7, 30)).withHoldShelfExpiration(LocalDate.of(2017, 8, 31)).withPickupServicePointId(pickupServicePointId).withTags(new RequestBuilder.Tags(asList("new", "important"))));
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 1);
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) HoldingBuilder(api.support.builders.HoldingBuilder) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 5 with HoldingBuilder

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

the class RequestScheduledNoticesProcessingTests method beforeEach.

@BeforeEach
public void beforeEach() {
    ItemBuilder itemBuilder = ItemExamples.basedUponSmallAngryPlanet(materialTypesFixture.book().getId(), loanTypesFixture.canCirculate().getId());
    HoldingBuilder holdingBuilder = itemsFixture.applyCallNumberHoldings("CN", "Prefix", "Suffix", singletonList("CopyNumbers"));
    item = itemsFixture.basedUponSmallAngryPlanet(itemBuilder, holdingBuilder);
    requester = usersFixture.steve();
    pickupServicePoint = servicePointsFixture.cd1();
    templateFixture.createDummyNoticeTemplate(TEMPLATE_ID);
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) HoldingBuilder(api.support.builders.HoldingBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

HoldingBuilder (api.support.builders.HoldingBuilder)6 ItemBuilder (api.support.builders.ItemBuilder)5 IndividualResource (api.support.http.IndividualResource)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)2 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)2 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)2 RequestBuilder (api.support.builders.RequestBuilder)2 ItemResource (api.support.http.ItemResource)2 JsonObject (io.vertx.core.json.JsonObject)2 ZonedDateTime (java.time.ZonedDateTime)2 UUID (java.util.UUID)2 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)2 Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 HashMap (java.util.HashMap)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matcher (org.hamcrest.Matcher)1 Matchers.emptyString (org.hamcrest.Matchers.emptyString)1