use of api.support.builders.NoticePolicyBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method requestCreationDoesNotFailWhenCirculationRulesReferenceInvalidNoticePolicyId.
@Test
void requestCreationDoesNotFailWhenCirculationRulesReferenceInvalidNoticePolicyId() {
UUID invalidNoticePolicyId = UUID.randomUUID();
IndividualResource record = noticePoliciesFixture.create(new NoticePolicyBuilder().withId(invalidNoticePolicyId).withName("Example NoticePolicy"));
setInvalidNoticePolicyReferenceInRules(invalidNoticePolicyId.toString());
noticePoliciesFixture.delete(record);
IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource steve = usersFixture.steve();
final IndividualResource createdRequest = requestsFixture.place(new RequestBuilder().open().page().forItem(smallAngryPlanet).by(steve).withRequestDate(ClockUtil.getZonedDateTime()).fulfilToHoldShelf().withPickupServicePointId(servicePointsFixture.cd1().getId()));
assertThat(createdRequest.getResponse(), hasStatus(HTTP_CREATED));
}
use of api.support.builders.NoticePolicyBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method recallNoticeToLoanOwnerIsSentForMovedRecallIfDueDateIsNotChanged.
@Test
void recallNoticeToLoanOwnerIsSentForMovedRecallIfDueDateIsNotChanged() {
UUID recallToLoanOwnerTemplateId = UUID.randomUUID();
JsonObject recallToLoanOwnerNoticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(recallToLoanOwnerTemplateId).withEventType(ITEM_RECALLED).create();
NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with recall notice").withLoanNotices(Collections.singletonList(recallToLoanOwnerNoticeConfiguration));
LoanPolicyBuilder loanPolicy = new LoanPolicyBuilder().withName("Policy with recall notice").withDescription("Recall configuration has no effect on due date").rolling(Period.weeks(3)).withClosedLibraryDueDateManagement(DueDateManagement.KEEP_THE_CURRENT_DUE_DATE.getValue()).withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(3)).withRecallsRecallReturnInterval(Period.weeks(1));
useFallbackPolicies(loanPoliciesFixture.create(loanPolicy).getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.create(noticePolicy).getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
UUID pickupServicePointId = servicePointsFixture.cd1().getId();
List<ItemResource> items = itemsFixture.createMultipleItemsForTheSameInstance(2);
IndividualResource itemToMoveTo = items.get(0);
IndividualResource itemToMoveFrom = items.get(1);
IndividualResource requester = usersFixture.rebecca();
IndividualResource loanOwner = usersFixture.jessica();
ZonedDateTime loanDate = ZonedDateTime.of(2020, 7, 22, 10, 22, 54, 0, UTC);
checkOutFixture.checkOutByBarcode(itemToMoveTo, loanOwner, loanDate);
checkOutFixture.checkOutByBarcode(itemToMoveFrom, loanOwner, loanDate);
ZonedDateTime requestDate = loanDate.plusDays(1);
mockClockManagerToReturnFixedDateTime(requestDate);
IndividualResource recallRequest = requestsFixture.place(new RequestBuilder().withId(UUID.randomUUID()).open().recall().forItem(itemToMoveFrom).by(requester).withRequestDate(requestDate).fulfilToHoldShelf().withRequestExpiration(LocalDate.of(2020, 7, 30)).withHoldShelfExpiration(LocalDate.of(2020, 8, 31)).withPickupServicePointId(pickupServicePointId).withTags(new RequestBuilder.Tags(asList("new", "important"))));
requestsFixture.move(new MoveRequestBuilder(recallRequest.getId(), itemToMoveTo.getId(), RECALL.getValue()));
// Recall notice to loan owner should be sent twice without changing due date
verifyNumberOfSentNotices(2);
verifyNumberOfPublishedEvents(NOTICE, 2);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
use of api.support.builders.NoticePolicyBuilder 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)));
}
use of api.support.builders.NoticePolicyBuilder in project mod-circulation by folio-org.
the class RequestsAPICreationTests method itemCheckOutRecallRequestCreationShouldProduceNotice.
@Test
void itemCheckOutRecallRequestCreationShouldProduceNotice() {
configurationsFixture.enableTlrFeature();
JsonObject recallToLoaneeConfiguration = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withEventType(NoticeEventType.ITEM_RECALLED.getRepresentation()).create();
JsonObject recallRequestToRequesterConfiguration = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withEventType(NoticeEventType.RECALL_REQUEST.getRepresentation()).create();
NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with recall notice").withLoanNotices(List.of(recallToLoaneeConfiguration, recallRequestToRequesterConfiguration));
useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.create(noticePolicy).getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
IndividualResource requester = usersFixture.steve();
ZonedDateTime requestDate = ZonedDateTime.of(2017, 7, 22, 10, 22, 54, 0, UTC);
checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
requestsFixture.placeItemLevelHoldShelfRequest(item, requester, requestDate, "Recall");
// notice for the recall is expected
verifyNumberOfSentNotices(2);
verifyNumberOfPublishedEvents(NOTICE, 2);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
List<JsonObject> noticeLogContextItemLogs = FakePubSub.getPublishedEventsAsList(byLogEventType(NOTICE));
// verify noticeLogContextItemLogs
validateNoticeLogContextItem(noticeLogContextItemLogs.get(0), item);
validateNoticeLogContextItem(noticeLogContextItemLogs.get(1), item);
}
use of api.support.builders.NoticePolicyBuilder in project mod-circulation by folio-org.
the class OverdueFineScheduledNoticesProcessingTests method generateOverdueFine.
private void generateOverdueFine(TriggeringEvent triggeringEvent, JsonObject... patronNoticeConfigs) {
NoticePolicyBuilder noticePolicyBuilder = new NoticePolicyBuilder().withName("Patron notice policy with fee/fine notices").withFeeFineNotices(Arrays.asList(patronNoticeConfigs));
use(noticePolicyBuilder);
templateFixture.createDummyNoticeTemplate(TEMPLATE_IDS.get(UPON_AT));
templateFixture.createDummyNoticeTemplate(TEMPLATE_IDS.get(AFTER));
UUID checkInServicePointId = servicePointsFixture.cd1().getId();
IndividualResource location = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(checkInServicePointId));
IndividualResource user = usersFixture.james();
userId = user.getId();
IndividualResource item = itemsFixture.basedUponNod(builder -> builder.withPermanentLocation(location.getId()));
itemId = item.getId();
JsonObject servicePointOwner = new JsonObject().put("value", checkInServicePointId.toString()).put("label", "Service Desk 1");
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(randomUUID()).withOwner("test owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
feeFinesClient.create(new FeeFineBuilder().withId(randomUUID()).withFeeFineType(OVERDUE_FINE).withAutomatic(true));
final ZonedDateTime checkOutDate = ClockUtil.getZonedDateTime().minusYears(1);
final ZonedDateTime checkInDate = checkOutDate.plusMonths(1);
IndividualResource checkOutResponse = checkOutFixture.checkOutByBarcode(item, user, checkOutDate);
loanId = UUID.fromString(checkOutResponse.getJson().getString("id"));
switch(triggeringEvent) {
case OVERDUE_FINE_RETURNED:
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(item).on(checkInDate).at(checkInServicePointId));
break;
case OVERDUE_FINE_RENEWED:
loansFixture.renewLoan(item, user);
break;
default:
break;
}
List<JsonObject> accounts = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(accountsClient::getAll, hasSize(1));
assertThat("Fee/fine record should have been created", accounts, hasSize(1));
account = Account.from(accounts.get(0));
accountId = UUID.fromString(account.getId());
List<JsonObject> actions = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(feeFineActionsClient::getAll, hasSize(1));
assertThat("Fee/fine action record should have been created", actions, hasSize(1));
action = FeeFineAction.from(actions.get(0));
actionId = UUID.fromString(action.getId());
actionDateTime = action.getDateAction();
}
Aggregations