Search in sources :

Example 1 with MultipleJsonRecords

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

Example 2 with MultipleJsonRecords

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));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) Test(org.junit.jupiter.api.Test)

Example 3 with MultipleJsonRecords

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

Example 4 with MultipleJsonRecords

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

Example 5 with MultipleJsonRecords

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

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