use of api.support.fakes.PublishedEvents in project mod-circulation by folio-org.
the class RequestsAPICreationTests method canCreateTlrRecallForInstanceWithSingleItemAndTwoLoans.
@Test
void canCreateTlrRecallForInstanceWithSingleItemAndTwoLoans() {
reconfigureTlrFeature(TlrFeatureStatus.ENABLED);
final ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource requestPickupServicePoint = servicePointsFixture.cd1();
IndividualResource initialLoan = checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
checkInFixture.checkInByBarcode(item);
IndividualResource dueDateChangeLoan = checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
requestsClient.create(new RequestBuilder().recall().withNoHoldingsRecordId().withNoItemId().titleRequestLevel().withInstanceId(item.getInstanceId()).withPickupServicePointId(requestPickupServicePoint.getId()).withRequesterId(usersFixture.james().getId()));
PublishedEvents publishedEvents = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(FakePubSub::getPublishedEvents, hasSize(9));
JsonObject loanWithoutChange = loansClient.get(initialLoan.getId()).getJson();
assertNull(loanWithoutChange.getString("dueDateChangedByRecall"));
JsonObject updatedLoan = loansClient.get(dueDateChangeLoan.getId()).getJson();
assertThat(updatedLoan.getString("dueDateChangedByRecall"), true);
JsonObject event = publishedEvents.findFirst(byEventType("LOAN_DUE_DATE_CHANGED"));
assertThat(event, isValidLoanDueDateChangedEvent(updatedLoan));
assertThat(new JsonObject(event.getString("eventPayload")).getBoolean("dueDateChangedByRecall"), equalTo(true));
}
Aggregations