use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class InHouseUseCheckInTest method isInHouseUseWhenItemHasClosedRequests.
@Test
void isInHouseUseWhenItemHasClosedRequests() {
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withTemporaryLocation(homeLocation.getId()));
requestsFixture.place(new RequestBuilder().page().forItem(nod).withPickupServicePointId(checkInServicePointId).by(usersFixture.james()));
IndividualResource recallRequest = requestsFixture.place(new RequestBuilder().recall().forItem(nod).withPickupServicePointId(checkInServicePointId).by(usersFixture.charlotte()));
requestsFixture.cancelRequest(recallRequest);
// Fulfill the page request
checkOutFixture.checkOutByBarcode(nod, usersFixture.james());
checkInFixture.checkInByBarcode(nod, checkInServicePointId);
final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(nod, checkInServicePointId);
assertThat(checkInResponse.getJson().containsKey("loan"), is(false));
assertThat(checkInResponse.getJson().containsKey("item"), is(true));
assertThat(checkInResponse.getInHouseUse(), is(true));
verifyLastCheckInWasRecorded(nod.getId(), checkInServicePointId);
MultipleJsonRecords requestsForItem = requestsFixture.getRequests(queryFromTemplate("itemId=%s", nod.getId()), noLimit(), noOffset());
assertThat(requestsForItem.totalRecords(), is(2));
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class LoanAPITests method canFindNoResultsFromSearch.
@Test
void canFindNoResultsFromSearch() {
MultipleJsonRecords loans = loansFixture.getLoans(queryFromTemplate("userId=%s", UUID.randomUUID()));
assertThat(loans.size(), is(0));
assertThat(loans.totalRecords(), is(0));
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class LoanAPITests method canCreateMultipleLoansWithServicePoints.
@Test
void canCreateMultipleLoansWithServicePoints() {
ZonedDateTime loanDate = ZonedDateTime.of(2017, 2, 27, 10, 23, 43, 0, UTC);
ZonedDateTime dueDate = ZonedDateTime.of(2017, 3, 29, 10, 23, 43, 0, UTC);
UUID checkinServicePointId = servicePointsFixture.cd1().getId();
UUID checkoutServicePointId = servicePointsFixture.cd2().getId();
UUID userId = usersFixture.charlotte().getId();
UUID loan1Id = UUID.randomUUID();
UUID item1Id = itemsFixture.basedUponDunkirk().getId();
UUID loan2Id = UUID.randomUUID();
UUID item2Id = itemsFixture.basedUponSmallAngryPlanet().getId();
UUID loan3Id = UUID.randomUUID();
UUID item3Id = itemsFixture.basedUponUprooted().getId();
loansFixture.createLoan(new LoanBuilder().withId(loan1Id).open().withUserId(userId).withItemId(item1Id).withLoanDate(loanDate).withDueDate(dueDate).withCheckinServicePointId(checkinServicePointId).withCheckoutServicePointId(checkoutServicePointId));
loansFixture.createLoan(new LoanBuilder().withId(loan2Id).open().withUserId(userId).withItemId(item2Id).withLoanDate(loanDate).withDueDate(dueDate).withCheckinServicePointId(checkinServicePointId).withCheckoutServicePointId(checkoutServicePointId));
loansFixture.createLoan(new LoanBuilder().withId(loan3Id).open().withUserId(userId).withItemId(item3Id).withLoanDate(loanDate).withDueDate(dueDate).withCheckinServicePointId(checkinServicePointId).withCheckoutServicePointId(checkoutServicePointId));
MultipleJsonRecords loanList = loansFixture.getAllLoans();
loanList.forEach(loanJson -> {
loanHasCheckinServicePointProperties(loanJson);
loanHasCheckoutServicePointProperties(loanJson);
});
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class LoanAPITests method canGetMultipleLoansWithoutUserId.
@Test
void canGetMultipleLoansWithoutUserId() {
UUID smallAngryPlanetId = itemsFixture.basedUponSmallAngryPlanet().getId();
UUID nodId = itemsFixture.basedUponNod().getId();
UUID checkinServicePointId = servicePointsFixture.cd1().getId();
UUID checkinServicePointId2 = servicePointsFixture.cd2().getId();
LoanBuilder smallAngryPlanetLoanBuilder = new LoanBuilder().withItemId(smallAngryPlanetId).withCheckinServicePointId(checkinServicePointId).closed().withNoUserId();
UUID userId = usersFixture.charlotte().getId();
loansFixture.createLoan(smallAngryPlanetLoanBuilder.withUserId(userId));
loansClient.createAtSpecificLocation(smallAngryPlanetLoanBuilder);
LoanBuilder nodLoanBuilder = new LoanBuilder().withItemId(nodId).closed().withCheckinServicePointId(checkinServicePointId2).withNoUserId();
loansFixture.createLoan(nodLoanBuilder.withUserId(userId));
loansClient.createAtSpecificLocation(nodLoanBuilder);
final MultipleJsonRecords multipleLoans = loansFixture.getAllLoans();
assertThat("Should have two loans", multipleLoans.size(), is(2));
multipleLoans.forEach(this::hasNoBorrowerProperties);
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class LoanAPITests method canGetMultipleAnonymizedLoans.
@Test
void canGetMultipleAnonymizedLoans() {
ItemResource firstItem = itemsFixture.basedUponSmallAngryPlanet();
IndividualResource jessica = usersFixture.jessica();
IndividualResource firstLoan = checkOutFixture.checkOutByBarcode(firstItem, jessica, ZonedDateTime.of(2018, 4, 21, 11, 21, 43, 0, UTC));
ItemResource secondItem = itemsFixture.basedUponNod();
IndividualResource henry = usersFixture.undergradHenry();
IndividualResource secondLoan = checkOutFixture.checkOutByBarcode(secondItem, henry, ZonedDateTime.of(2018, 4, 21, 11, 21, 43, 0, UTC));
JsonObject firstSavedLoan = loansStorageClient.get(firstLoan.getId()).getResponse().getJson();
firstSavedLoan.remove("userId");
loansStorageClient.replace(firstLoan.getId(), firstSavedLoan);
JsonObject secondSavedLoan = loansStorageClient.get(secondLoan.getId()).getResponse().getJson();
secondSavedLoan.remove("userId");
loansStorageClient.replace(secondLoan.getId(), secondSavedLoan);
MultipleJsonRecords loans = loansFixture.getAllLoans();
JsonObject fetchedLoan1 = loans.getById(firstLoan.getId());
JsonObject fetchedLoan2 = loans.getById(secondLoan.getId());
loanHasPatronGroupProperties(fetchedLoan1, "Regular Group");
loanHasPatronGroupProperties(fetchedLoan2, "undergrad");
}
Aggregations