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));
}
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);
}
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"));
}
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"))));
}
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"))));
}
Aggregations