Search in sources :

Example 1 with PublishedEvents

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));
}
Also used : FakePubSub(api.support.fakes.FakePubSub) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) PublishedEvents(api.support.fakes.PublishedEvents) PatronNoticeTestHelper.verifyNumberOfPublishedEvents(api.support.utl.PatronNoticeTestHelper.verifyNumberOfPublishedEvents) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

MoveRequestBuilder (api.support.builders.MoveRequestBuilder)1 RequestBuilder (api.support.builders.RequestBuilder)1 FakePubSub (api.support.fakes.FakePubSub)1 PublishedEvents (api.support.fakes.PublishedEvents)1 IndividualResource (api.support.http.IndividualResource)1 ItemResource (api.support.http.ItemResource)1 PatronNoticeTestHelper.verifyNumberOfPublishedEvents (api.support.utl.PatronNoticeTestHelper.verifyNumberOfPublishedEvents)1 JsonObject (io.vertx.core.json.JsonObject)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1