use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class DeclareLostAPITests method shouldNotCreateNoteWhenNotPreviouslyClaimedReturned.
@Test
void shouldNotCreateNoteWhenNotPreviouslyClaimedReturned() {
String comment = "testing";
UUID servicePointId = servicePointsFixture.cd1().getId();
ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
UUID loanId = checkOutFixture.checkOutByBarcode(item, usersFixture.charlotte()).getId();
ZonedDateTime dateTime = getZonedDateTime();
final DeclareItemLostRequestBuilder builder = new DeclareItemLostRequestBuilder().forLoanId(loanId).on(dateTime).withServicePointId(servicePointId).withComment(comment);
declareLostFixtures.declareItemLost(builder);
assertEquals(0, notesClient.getAll().size());
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class DeclareLostAPITests method cannotDeclareItemLostWhenNoAutomatedLostItemFeeTypeIsDefined.
@Test
void cannotDeclareItemLostWhenNoAutomatedLostItemFeeTypeIsDefined() {
UUID servicePointId = servicePointsFixture.cd1().getId();
feeFineTypeFixture.delete(feeFineTypeFixture.lostItemFee());
final ItemResource item = itemsFixture.basedUponNod();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(item, usersFixture.charlotte());
final Response response = declareLostFixtures.attemptDeclareItemLost(new DeclareItemLostRequestBuilder().withServicePointId(servicePointId).forLoanId(loan.getId()));
assertThat(loansFixture.getLoanById(loan.getId()).getJson(), isOpen());
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Expected automated fee of type Lost item fee"), hasParameter("feeFineType", "Lost item fee"))));
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class DeclareLostAPITests method shouldNotChargeFeesWhenPolicyIsUnknown.
@Test
void shouldNotChargeFeesWhenPolicyIsUnknown() {
UUID servicePointId = servicePointsFixture.cd1().getId();
final ItemResource item = itemsFixture.basedUponNod();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(item, usersFixture.charlotte());
final JsonObject loanWithoutLostPolicy = loansStorageClient.getById(loan.getId()).getJson().copy();
loanWithoutLostPolicy.remove("lostItemPolicyId");
loansStorageClient.replace(loan.getId(), loanWithoutLostPolicy);
assertThat(loansStorageClient.getById(loan.getId()).getJson().getString("lostItemPolicyId"), nullValue());
declareLostFixtures.declareItemLost(new DeclareItemLostRequestBuilder().forLoanId(loan.getId()).withServicePointId(servicePointId));
verifyLoanIsClosed(loan.getId());
assertThat(getAccountsForLoan(loan.getId()), hasSize(0));
assertThatPublishedLoanLogRecordEventsAreValid(loansClient.getById(loan.getId()).getJson());
verifyNumberOfPublishedEvents(ITEM_DECLARED_LOST, 0);
verifyNumberOfPublishedEvents(LOAN_CLOSED, 1);
verifyThatFirstPublishedLoanClosedEventIsValid(loan);
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class DueDateNotRealTimeScheduledNoticesProcessingTests method noticeIsNotSentOrDeletedWhenPatronNoticeRequestFails.
@Test
void noticeIsNotSentOrDeletedWhenPatronNoticeRequestFails() {
JsonObject uponAtDueDateNoticeConfig = new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withDueDateEvent().withUponAtTiming().sendInRealTime(false).create();
NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with due date notices").withLoanNotices(Collections.singletonList(uponAtDueDateNoticeConfig));
use(noticePolicy);
ZonedDateTime loanDate = ZonedDateTime.of(2019, 8, 23, 10, 30, 0, 0, ZoneOffset.UTC);
IndividualResource james = usersFixture.james();
ItemResource nod = itemsFixture.basedUponNod();
IndividualResource nodToJamesLoan = checkOutFixture.checkOutByBarcode(nod, james, loanDate);
verifyNumberOfScheduledNotices(1);
ZonedDateTime dueDate = parseDateTime(nodToJamesLoan.getJson().getString("dueDate"));
ZonedDateTime afterLoanDueDateTime = dueDate.plusDays(1);
FakeModNotify.setFailPatronNoticesWithBadRequest(true);
scheduledNoticeProcessingClient.runDueDateNotRealTimeNoticesProcessing(afterLoanDueDateTime);
verifyNumberOfSentNotices(0);
verifyNumberOfScheduledNotices(1);
verifyNumberOfPublishedEvents(NOTICE, 0);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 1);
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class DueDateNotRealTimeScheduledNoticesProcessingTests method uponAtDueDateNoticesShouldBeSentInGroups.
@Test
void uponAtDueDateNoticesShouldBeSentInGroups() {
JsonObject uponAtDueDateNoticeConfig = new NoticeConfigurationBuilder().withTemplateId(TEMPLATE_ID).withDueDateEvent().withUponAtTiming().sendInRealTime(false).create();
NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with due date notices").withLoanNotices(Collections.singletonList(uponAtDueDateNoticeConfig));
use(noticePolicy);
ZonedDateTime loanDate = ZonedDateTime.of(2019, 8, 23, 10, 30, 0, 0, ZoneOffset.UTC);
IndividualResource james = usersFixture.james();
ItemResource nod = itemsFixture.basedUponNod();
ItemResource interestingTimes = itemsFixture.basedUponInterestingTimes();
IndividualResource nodToJamesLoan = checkOutFixture.checkOutByBarcode(nod, james, loanDate);
IndividualResource interestingTimesToJamesLoan = checkOutFixture.checkOutByBarcode(interestingTimes, james, loanDate);
IndividualResource rebecca = usersFixture.rebecca();
ItemResource temeraire = itemsFixture.basedUponTemeraire();
ItemResource dunkirk = itemsFixture.basedUponDunkirk();
IndividualResource temeraireToRebeccaLoan = checkOutFixture.checkOutByBarcode(temeraire, rebecca, loanDate);
IndividualResource dunkirkToRebeccaLoan = checkOutFixture.checkOutByBarcode(dunkirk, rebecca, loanDate);
verifyNumberOfScheduledNotices(4);
ZonedDateTime dueDate = parseDateTime(nodToJamesLoan.getJson().getString("dueDate"));
ZonedDateTime afterLoanDueDateTime = dueDate.plusDays(1);
scheduledNoticeProcessingClient.runDueDateNotRealTimeNoticesProcessing(afterLoanDueDateTime);
final var loanPolicyMatcher = toStringMatcher(getLoanPolicyContextMatchersForUnlimitedRenewals());
final var noticeToJamesContextMatcher = getMultipleLoansContextMatcher(james, Arrays.asList(Pair.of(nodToJamesLoan, nod), Pair.of(interestingTimesToJamesLoan, interestingTimes)), loanPolicyMatcher);
final var noticeToRebeccaContextMatcher = getMultipleLoansContextMatcher(rebecca, Arrays.asList(Pair.of(temeraireToRebeccaLoan, temeraire), Pair.of(dunkirkToRebeccaLoan, dunkirk)), loanPolicyMatcher);
assertThat(FakeModNotify.getSentPatronNotices(), hasItems(hasEmailNoticeProperties(james.getId(), TEMPLATE_ID, noticeToJamesContextMatcher), hasEmailNoticeProperties(rebecca.getId(), TEMPLATE_ID, noticeToRebeccaContextMatcher)));
verifyNumberOfSentNotices(2);
verifyNumberOfScheduledNotices(0);
verifyNumberOfPublishedEvents(NOTICE, 2);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Aggregations