Search in sources :

Example 21 with ItemResource

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());
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) UUID(java.util.UUID) DeclareItemLostRequestBuilder(api.support.builders.DeclareItemLostRequestBuilder) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with ItemResource

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"))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) DeclareItemLostRequestBuilder(api.support.builders.DeclareItemLostRequestBuilder) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with ItemResource

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);
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) DeclareItemLostRequestBuilder(api.support.builders.DeclareItemLostRequestBuilder) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with ItemResource

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

Example 25 with ItemResource

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

Aggregations

ItemResource (api.support.http.ItemResource)232 Test (org.junit.jupiter.api.Test)218 IndividualResource (api.support.http.IndividualResource)189 JsonObject (io.vertx.core.json.JsonObject)138 UUID (java.util.UUID)127 RequestBuilder (api.support.builders.RequestBuilder)117 Response (org.folio.circulation.support.http.client.Response)89 ZonedDateTime (java.time.ZonedDateTime)81 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)61 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)40 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)39 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)38 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)36 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)32 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)27 ItemBuilder (api.support.builders.ItemBuilder)21 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)13 UserResource (api.support.http.UserResource)13 HashMap (java.util.HashMap)13 Matcher (org.hamcrest.Matcher)13