use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class RequestsAPIRetrievalTests method canSearchForRequestsByInstanceTitle.
@Test
void canSearchForRequestsByInstanceTitle() {
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));
final MultipleJsonRecords requests = requestsFixture.getRequests(queryFromTemplate("instance.title=%s", "Nod"), noLimit(), noOffset());
assertThat(requests.size(), is(2));
assertThat(requests.totalRecords(), is(2));
requests.forEach(this::requestHasExpectedProperties);
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class RequestsAPIRetrievalTests method canGetMultipleRequests.
@Test
void canGetMultipleRequests() {
final IndividualResource cd1 = servicePointsFixture.cd1();
final IndividualResource cd2 = servicePointsFixture.cd2();
UUID pickupServicePointId = cd1.getId();
UUID pickupServicePointId2 = cd2.getId();
UUID facultyGroupId = patronGroupsFixture.faculty().getId();
UUID staffGroupId = patronGroupsFixture.staff().getId();
final IndividualResource jessica = usersFixture.jessica();
final IndividualResource charlotte = usersFixture.charlotte();
final IndividualResource sponsor = usersFixture.rebecca(user -> user.withPatronGroupId(facultyGroupId));
final IndividualResource proxy = usersFixture.steve(user -> user.withPatronGroupId(staffGroupId));
UUID proxyId = proxy.getId();
UUID requesterId = sponsor.getId();
proxyRelationshipsFixture.nonExpiringProxyFor(sponsor, proxy);
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final IndividualResource nod = itemsFixture.basedUponNod(itemsFixture.addCallNumberStringComponents("nod"));
final IndividualResource interestingTimes = itemsFixture.basedUponInterestingTimes();
final IndividualResource temeraire = itemsFixture.basedUponTemeraire(itemsFixture.addCallNumberStringComponents("tem"));
final IndividualResource uprooted = itemsFixture.basedUponUprooted();
checkOutFixture.checkOutByBarcode(smallAngryPlanet, jessica);
checkOutFixture.checkOutByBarcode(nod, charlotte);
checkOutFixture.checkOutByBarcode(interestingTimes, charlotte);
checkOutFixture.checkOutByBarcode(temeraire, jessica);
checkOutFixture.checkOutByBarcode(uprooted, jessica);
requestsFixture.place(new RequestBuilder().hold().forItem(smallAngryPlanet).withRequesterId(requesterId).withUserProxyId(proxyId).withPickupServicePointId(pickupServicePointId).withTags(new RequestBuilder.Tags(asList(NEW_TAG, IMPORTANT_TAG))));
final IndividualResource requestForNod = requestsFixture.place(new RequestBuilder().hold().forItem(nod).withRequesterId(requesterId).withUserProxyId(proxyId).withPickupServicePointId(pickupServicePointId2).withPatronComments("Comment 2").withTags(new RequestBuilder.Tags(asList(NEW_TAG, IMPORTANT_TAG))));
requestsFixture.place(new RequestBuilder().hold().forItem(interestingTimes).withRequesterId(requesterId).withUserProxyId(proxyId).withPickupServicePointId(pickupServicePointId).withPatronComments("Comment 3").withTags(new RequestBuilder.Tags(asList(NEW_TAG, IMPORTANT_TAG))));
final IndividualResource requestForTemeraire = requestsFixture.place(new RequestBuilder().hold().forItem(temeraire).withRequesterId(requesterId).withUserProxyId(proxyId).withPickupServicePointId(pickupServicePointId2).withPatronComments("Comment 4").withTags(new RequestBuilder.Tags(asList(NEW_TAG, IMPORTANT_TAG))));
requestsFixture.place(new RequestBuilder().recall().forItem(uprooted).withRequesterId(requesterId).withUserProxyId(proxyId).withPickupServicePointId(pickupServicePointId).withPatronComments("Comment 5").withTags(new RequestBuilder.Tags(asList(NEW_TAG, IMPORTANT_TAG))));
MultipleJsonRecords requests = requestsFixture.getAllRequests();
requests.forEach(this::requestHasExpectedProperties);
requests.forEach(this::requestHasExpectedLoanProperties);
requests.forEach(this::requestHasServicePointProperties);
requests.forEach(this::requestHasPatronGroupProperties);
requests.forEach(this::requestHasTags);
requestHasCallNumberStringProperties(requests.getById(requestForNod.getId()), "nod");
requestHasCallNumberStringProperties(requests.getById(requestForTemeraire.getId()), "tem");
assertThatRequestsHavePatronComments(requests);
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class CancelRequestTests method shouldAllowToCancelRequestWithNoPosition.
@Test
void shouldAllowToCancelRequestWithNoPosition() {
IndividualResource requesterId = usersFixture.rebecca();
final ItemResource nod = itemsFixture.basedUponNod();
checkOutFixture.checkOutByBarcode(nod, requesterId);
IndividualResource firstHoldRequest = holdRequestWithNoPosition(nod, usersFixture.steve());
IndividualResource secondHoldRequest = holdRequestWithNoPosition(nod, usersFixture.charlotte());
requestsFixture.cancelRequest(firstHoldRequest);
requestsFixture.cancelRequest(secondHoldRequest);
MultipleJsonRecords allRequests = requestsFixture.getAllRequests();
assertThat(allRequests.totalRecords(), is(2));
JsonObject firstRequest = allRequests.getById(firstHoldRequest.getId());
JsonObject secondRequest = allRequests.getById(secondHoldRequest.getId());
assertThat(firstRequest.getString("status"), is(CLOSED_CANCELLED.getValue()));
assertThat(secondRequest.getString("status"), is(CLOSED_CANCELLED.getValue()));
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class InHouseUseCheckInTest method verifyLastCheckInWasRecorded.
private void verifyLastCheckInWasRecorded(UUID itemId, UUID servicePoint) {
final CqlQuery query = queryFromTemplate("itemId=%s and itemStatusPriorToCheckIn=Available", itemId);
final MultipleJsonRecords recordedOperations = checkInOperationClient.getMany(query);
assertThat(recordedOperations.totalRecords(), greaterThan(0));
final String itemEffectiveLocationId = itemsClient.getById(itemId).getJson().getString("effectiveLocationId");
final JsonObject lastOperation = recordedOperations.getFirst();
assertThat(lastOperation.getString("occurredDateTime"), withinSecondsBeforeNow(2));
assertThat(lastOperation.getString("itemId"), is(itemId.toString()));
assertThat(lastOperation.getString("servicePointId"), is(servicePoint.toString()));
assertThat(lastOperation.getString("performedByUserId"), is(getUserId()));
assertThat(lastOperation.getString("itemStatusPriorToCheckIn"), is("Available"));
assertThat(lastOperation.getString("itemLocationId"), is(itemEffectiveLocationId));
assertThat(lastOperation.getInteger("requestQueueSize"), is(0));
assertTrue(isServedByServicePoint(UUID.fromString(itemEffectiveLocationId), servicePoint));
}
use of api.support.MultipleJsonRecords in project mod-circulation by folio-org.
the class LoanAPITests method canSearchByUserId.
@Test
void canSearchByUserId() {
val firstUser = usersFixture.steve();
UUID firstUserId = firstUser.getId();
val secondUser = usersFixture.jessica();
UUID secondUserId = secondUser.getId();
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponSmallAngryPlanet()).withUserId(firstUserId));
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponNod()).withUserId(firstUserId));
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponSmallAngryPlanet()).withUserId(firstUserId));
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponTemeraire()).withUserId(firstUserId));
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponUprooted()).withUserId(secondUserId));
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponNod()).withUserId(secondUserId));
loansFixture.createLoan(new LoanBuilder().withItem(itemsFixture.basedUponInterestingTimes()).withUserId(secondUserId));
String queryTemplate = "userId=%s";
MultipleJsonRecords firstPage = loansFixture.getLoans(queryFromTemplate(queryTemplate, firstUserId));
MultipleJsonRecords secondPage = loansFixture.getLoans(queryFromTemplate(queryTemplate, secondUserId));
assertThat(firstPage.size(), is(4));
assertThat(firstPage.totalRecords(), is(4));
assertThat(secondPage.size(), is(3));
assertThat(secondPage.totalRecords(), is(3));
firstPage.forEach(loan -> loanHasExpectedProperties(loan, firstUser));
secondPage.forEach(loan -> loanHasExpectedProperties(loan, secondUser));
assertThat(countOfDistinctTitles(firstPage.stream()), is(greaterThan(1)));
assertThat(countOfDistinctTitles(secondPage.stream()), is(greaterThan(1)));
}
Aggregations