Search in sources :

Example 11 with MultipleJsonRecords

use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.

the class RequestsAPIRetrievalTests method closedLoanForItemIsNotIncludedWhenFindingMultipleRequests.

@Test
void closedLoanForItemIsNotIncludedWhenFindingMultipleRequests() {
    final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource charlotte = usersFixture.charlotte();
    final IndividualResource james = usersFixture.james();
    checkOutFixture.checkOutByBarcode(smallAngryPlanet, james);
    final IndividualResource workAddressType = addressTypesFixture.work();
    requestsFixture.place(new RequestBuilder().recall().forItem(smallAngryPlanet).deliverToAddress(workAddressType.getId()).by(charlotte));
    checkInFixture.checkInByBarcode(smallAngryPlanet);
    final MultipleJsonRecords allRequests = requestsFixture.getAllRequests();
    assertThat(allRequests.size(), is(1));
    JsonObject representation = allRequests.getFirst();
    // TODO: Figure out if this check makes sense?
    assertThat("Request should not have a current loan for the item", representation.containsKey("deliveryAddress"), is(false));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Example 12 with MultipleJsonRecords

use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.

the class RequestsAPIRetrievalTests method canPageAllRequests.

@Test
void canPageAllRequests() {
    UUID requesterId = usersFixture.charlotte().getId();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponSmallAngryPlanet(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponNod(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponInterestingTimes(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponTemeraire(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponNod(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponUprooted(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    requestsFixture.place(new RequestBuilder().forItem(itemsFixture.basedUponTemeraire(ItemBuilder::checkOut)).withPickupServicePointId(pickupServicePointId).withRequesterId(requesterId));
    MultipleJsonRecords firstPage = requestsFixture.getRequests(noQuery(), limit(4), noOffset());
    MultipleJsonRecords secondPage = requestsFixture.getRequests(noQuery(), limit(4), offset(4));
    assertThat(firstPage.size(), is(4));
    assertThat(firstPage.totalRecords(), is(7));
    assertThat(secondPage.size(), is(3));
    assertThat(secondPage.totalRecords(), is(7));
    firstPage.forEach(this::requestHasExpectedProperties);
    secondPage.forEach(this::requestHasExpectedProperties);
}
Also used : ItemBuilder(api.support.builders.ItemBuilder) MultipleJsonRecords(api.support.MultipleJsonRecords) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 13 with MultipleJsonRecords

use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.

the class RequestsAPIRetrievalTests method fulfilledByDeliveryIncludesAddressWhenFindingMultipleRequests.

@Test
void fulfilledByDeliveryIncludesAddressWhenFindingMultipleRequests() {
    final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource workAddressType = addressTypesFixture.work();
    final IndividualResource charlotte = usersFixture.charlotte(builder -> builder.withAddress(new Address(workAddressType.getId(), "Fake first address line", "Fake second address line", "Fake city", "Fake region", "Fake postal code", "Fake country code")));
    final IndividualResource james = usersFixture.james();
    checkOutFixture.checkOutByBarcode(smallAngryPlanet, james);
    requestsFixture.place(new RequestBuilder().recall().forItem(smallAngryPlanet).deliverToAddress(workAddressType.getId()).by(charlotte));
    final MultipleJsonRecords allRequests = requestsFixture.getAllRequests();
    assertThat(allRequests.size(), is(1));
    JsonObject representation = allRequests.getFirst();
    assertThat(representation.getString("id"), is(not(emptyString())));
    assertThat(representation.getString("requestType"), is("Recall"));
    assertThat(representation.getString("fulfilmentPreference"), is("Delivery"));
    assertThat(representation.getString("deliveryAddressTypeId"), is(workAddressType.getId()));
    assertThat("Request should have a delivery address", representation.containsKey("deliveryAddress"), is(true));
    final JsonObject deliveryAddress = representation.getJsonObject("deliveryAddress");
    assertThat(deliveryAddress.getString("addressTypeId"), is(workAddressType.getId()));
    assertThat(deliveryAddress.getString("addressLine1"), is("Fake first address line"));
    assertThat(deliveryAddress.getString("addressLine2"), is("Fake second address line"));
    assertThat(deliveryAddress.getString("city"), is("Fake city"));
    assertThat(deliveryAddress.getString("region"), is("Fake region"));
    assertThat(deliveryAddress.getString("postalCode"), is("Fake postal code"));
    assertThat(deliveryAddress.getString("countryId"), is("Fake country code"));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) Address(api.support.builders.Address) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Example 14 with MultipleJsonRecords

use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.

the class LoanDueDatesAfterRecallTests method shouldNotExtendLoanDueDateIfOverdueLoanIsRecalled.

@Test
void shouldNotExtendLoanDueDateIfOverdueLoanIsRecalled() {
    final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
    final Period loanPeriod = Period.weeks(3);
    setFallbackPolicies(new LoanPolicyBuilder().withName("Can Circulate Rolling With Recalls").withDescription("Can circulate item With Recalls").rolling(loanPeriod).unlimitedRenewals().renewFromSystemDate().withRecallsMinimumGuaranteedLoanPeriod(Period.weeks(2)).withRecallsRecallReturnInterval(Period.months(2)));
    final ZonedDateTime loanCreateDate = loanPeriod.minusDate(getZonedDateTime()).minusMinutes(1);
    final ZonedDateTime expectedLoanDueDate = loanPeriod.plusDate(loanCreateDate);
    final IndividualResource loan = checkOutFixture.checkOutByBarcode(smallAngryPlanet, usersFixture.steve(), loanCreateDate);
    requestsFixture.place(new RequestBuilder().recall().forItem(smallAngryPlanet).fulfilToHoldShelf().by(usersFixture.jessica()).fulfilToHoldShelf().withPickupServicePointId(servicePointsFixture.cd1().getId()));
    assertThat(loansStorageClient.getById(loan.getId()).getJson(), hasJsonPath("dueDate", isEquivalentTo(expectedLoanDueDate)));
    // verify that loan action is recorder even though due date is not changed
    final MultipleJsonRecords loanHistory = loanHistoryClient.getMany(queryFromTemplate("loan.id==%s and operation==U", loan.getId()));
    assertThat(loanHistory, hasItem(allOf(hasJsonPath("loan.action", "recallrequested"), hasJsonPath("loan.itemStatus", "Checked out"))));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) Period(org.folio.circulation.domain.policy.Period) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with MultipleJsonRecords

use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.

the class DeclareLostAPITests method verifyDeclaredLostHistoryRecordCreated.

private void verifyDeclaredLostHistoryRecordCreated(UUID loanId) {
    final MultipleJsonRecords loanHistory = loanHistoryClient.getMany(queryFromTemplate("loan.id==%s and operation==U", loanId));
    assertThat(loanHistory, hasItems(allOf(hasJsonPath("loan.action", "declaredLost"), hasJsonPath("loan.itemStatus", "Declared lost")), allOf(hasJsonPath("loan.status.name", "Closed"), hasJsonPath("loan.action", "closedLoan"), hasJsonPath("loan.itemStatus", "Lost and paid"))));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords)

Aggregations

MultipleJsonRecords (api.support.MultipleJsonRecords)25 Test (org.junit.jupiter.api.Test)21 IndividualResource (api.support.http.IndividualResource)12 UUID (java.util.UUID)12 RequestBuilder (api.support.builders.RequestBuilder)9 JsonObject (io.vertx.core.json.JsonObject)8 LoanBuilder (api.support.builders.LoanBuilder)6 ItemResource (api.support.http.ItemResource)5 ItemBuilder (api.support.builders.ItemBuilder)4 lombok.val (lombok.val)4 ZonedDateTime (java.time.ZonedDateTime)3 AccountBuilder (api.support.builders.AccountBuilder)2 CqlQuery (api.support.http.CqlQuery)2 RequestsAPICreationTests.setupMissingItem (api.requests.RequestsAPICreationTests.setupMissingItem)1 APITests (api.support.APITests)1 CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)1 Address (api.support.builders.Address)1 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)1 FakePubSub (api.support.fakes.FakePubSub)1 PublishedEvents.byEventType (api.support.fakes.PublishedEvents.byEventType)1