Search in sources :

Example 1 with ClaimItemReturnedRequestBuilder

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"));
}
Also used : Response(org.folio.circulation.support.http.client.Response) ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with ClaimItemReturnedRequestBuilder

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);
}
Also used : Response(org.folio.circulation.support.http.client.Response) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) ZonedDateTime(java.time.ZonedDateTime) ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with ClaimItemReturnedRequestBuilder

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());
}
Also used : Response(org.folio.circulation.support.http.client.Response) FakePubSub(api.support.fakes.FakePubSub) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) ZonedDateTime(java.time.ZonedDateTime) ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with ClaimItemReturnedRequestBuilder

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);
}
Also used : Response(org.folio.circulation.support.http.client.Response) ZonedDateTime(java.time.ZonedDateTime) ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Example 5 with ClaimItemReturnedRequestBuilder

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) AgeToLostResult(api.support.fixtures.AgeToLostFixture.AgeToLostResult) ClaimItemReturnedRequestBuilder(api.support.builders.ClaimItemReturnedRequestBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

ClaimItemReturnedRequestBuilder (api.support.builders.ClaimItemReturnedRequestBuilder)14 Test (org.junit.jupiter.api.Test)14 Response (org.folio.circulation.support.http.client.Response)11 ZonedDateTime (java.time.ZonedDateTime)9 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 JsonObject (io.vertx.core.json.JsonObject)3 DeclareClaimedReturnedItemAsMissingRequestBuilder (api.support.builders.DeclareClaimedReturnedItemAsMissingRequestBuilder)2 IndividualResource (api.support.http.IndividualResource)2 ItemResource (api.support.http.ItemResource)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ChangeDueDateRequestBuilder (api.support.builders.ChangeDueDateRequestBuilder)1 DeclareItemLostRequestBuilder (api.support.builders.DeclareItemLostRequestBuilder)1 FakePubSub (api.support.fakes.FakePubSub)1 AgeToLostResult (api.support.fixtures.AgeToLostFixture.AgeToLostResult)1 UUID (java.util.UUID)1