Search in sources :

Example 16 with MultipleJsonRecords

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);
}
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 17 with MultipleJsonRecords

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);
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) RequestBuilder(api.support.builders.RequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 18 with MultipleJsonRecords

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

Example 19 with MultipleJsonRecords

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));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) JsonObject(io.vertx.core.json.JsonObject) CqlQuery(api.support.http.CqlQuery)

Example 20 with MultipleJsonRecords

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)));
}
Also used : lombok.val(lombok.val) MultipleJsonRecords(api.support.MultipleJsonRecords) LoanBuilder(api.support.builders.LoanBuilder) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

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