use of api.support.builders.ClaimItemReturnedRequestBuilder in project mod-circulation by folio-org.
the class ClaimItemReturnedAPITests method claimItemReturnFailsWhenEventPublishingFailsWithBadRequestError.
@Test
void claimItemReturnFailsWhenEventPublishingFailsWithBadRequestError() {
FakePubSub.setFailPublishingWithBadRequestError(true);
final Response response = claimItemReturnedFixture.attemptClaimItemReturned(500, new ClaimItemReturnedRequestBuilder().forLoan(loanId).withItemClaimedReturnedDate(getZonedDateTime()).withComment("testing"));
assertThat(response.getBody(), containsString("Error during publishing Event Message in PubSub. Status code: 400"));
}
use of api.support.builders.ClaimItemReturnedRequestBuilder in project mod-circulation by folio-org.
the class ClaimItemReturnedAPITests method canClaimItemReturnedWithoutComment.
@Test
void canClaimItemReturnedWithoutComment() {
final ZonedDateTime dateTime = getZonedDateTime();
final Response response = claimItemReturnedFixture.claimItemReturned(new ClaimItemReturnedRequestBuilder().forLoan(loanId).withItemClaimedReturnedDate(dateTime));
assertLoanAndItem(response, null, dateTime);
}
use of api.support.builders.ClaimItemReturnedRequestBuilder in project mod-circulation by folio-org.
the class ClaimItemReturnedAPITests method itemClaimedReturnedEventIsPublished.
@Test
void itemClaimedReturnedEventIsPublished() {
final ZonedDateTime dateTime = ClockUtil.getZonedDateTime();
final Response response = claimItemReturnedFixture.claimItemReturned(new ClaimItemReturnedRequestBuilder().forLoan(loanId).withItemClaimedReturnedDate(dateTime));
assertLoanAndItem(response, null, dateTime);
// Five events are expected: one for check-out one for log event, one for the claim
// and one for log records
final var publishedEvents = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(FakePubSub::getPublishedEvents, hasSize(4));
final var event = publishedEvents.findFirst(byEventType(ITEM_CLAIMED_RETURNED));
assertThat(event, isValidItemClaimedReturnedEvent(loan.getJson()));
assertThatPublishedLoanLogRecordEventsAreValid(loansClient.getById(loan.getId()).getJson());
}
use of api.support.builders.ClaimItemReturnedRequestBuilder in project mod-circulation by folio-org.
the class ChangeDueDateByReplacingLoanTests method canManuallyReapplyTheDueDateOfClaimedReturnedLoan.
@Test
void canManuallyReapplyTheDueDateOfClaimedReturnedLoan() {
final ItemResource item = itemsFixture.basedUponNod();
IndividualResource loan = checkOutFixture.checkOutByBarcode(item);
final ClaimItemReturnedRequestBuilder claimedItemBuilder = (new ClaimItemReturnedRequestBuilder()).forLoan(loan.getId().toString());
Response claimedLoan = claimItemReturnedFixture.claimItemReturned(claimedItemBuilder);
assertThat(claimedLoan, hasStatus(HTTP_NO_CONTENT));
Response fetchedLoan = loansClient.getById(loan.getId());
JsonObject loanToChange = fetchedLoan.getJson().copy();
final ZonedDateTime dueDate = parseDateTime(loanToChange.getString("dueDate"));
write(loanToChange, "action", "dueDateChange");
write(loanToChange, "dueDate", dueDate);
loansFixture.replaceLoan(loan.getId(), loanToChange);
}
use of api.support.builders.ClaimItemReturnedRequestBuilder in project mod-circulation by folio-org.
the class AgedToLostScheduledNoticesProcessingTests method shouldStopSendingAgedToLostNoticesOnceItemIsClaimedReturned.
@Test
void shouldStopSendingAgedToLostNoticesOnceItemIsClaimedReturned() {
AgeToLostResult agedToLostLoan = createRecurringAgedToLostNotice();
claimItemReturnedFixture.claimItemReturned(new ClaimItemReturnedRequestBuilder().forLoan(agedToLostLoan.getLoanId().toString()).withItemClaimedReturnedDate(ClockUtil.getZonedDateTime()));
final ZonedDateTime firstRunTime = TIMING_PERIOD.plusDate(getAgedToLostDate(agedToLostLoan));
scheduledNoticeProcessingClient.runLoanNoticesProcessing(RECURRENCE_PERIOD.plusDate(firstRunTime).plusMinutes(1));
verifyNumberOfSentNotices(0);
verifyNumberOfScheduledNotices(0);
verifyNumberOfPublishedEvents(NOTICE, 0);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Aggregations