Search in sources :

Example 11 with ItemResource

use of api.support.http.ItemResource in project mod-circulation by folio-org.

the class ItemsInTransitReportTests method reportIncludesMultipleDifferentItemsInTransit.

@Test
void reportIncludesMultipleDifferentItemsInTransit() {
    final ItemResource smallAngryPlanet = createSmallAngryPlanet();
    final ItemResource nod = createNod();
    final IndividualResource steve = usersFixture.steve();
    final IndividualResource rebecca = usersFixture.rebecca();
    final UUID firsServicePointId = servicePointsFixture.cd1().getId();
    final UUID secondServicePointId = servicePointsFixture.cd2().getId();
    final ZonedDateTime checkInDate1 = ZonedDateTime.of(2019, 8, 13, 5, 0, 0, 0, UTC);
    final ZonedDateTime checkInDate2 = ZonedDateTime.of(2019, 4, 3, 2, 10, 0, 0, UTC);
    final ZonedDateTime requestDate1 = ZonedDateTime.of(2019, 7, 5, 10, 0, 0, 0, UTC);
    final LocalDate requestExpirationDate1 = LocalDate.of(2019, 7, 11);
    final ZonedDateTime requestDate2 = ZonedDateTime.of(2019, 10, 8, 11, 0, 0, 0, UTC);
    final LocalDate requestExpirationDate2 = LocalDate.of(2020, 1, 12);
    checkOutFixture.checkOutByBarcode(smallAngryPlanet);
    checkOutFixture.checkOutByBarcode(nod);
    createRequest(smallAngryPlanet, steve, secondServicePointId, requestDate1, requestExpirationDate1);
    createRequest(nod, rebecca, secondServicePointId, requestDate2, requestExpirationDate2);
    mockClockManagerToReturnFixedDateTime(checkInDate1);
    checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(smallAngryPlanet).on(checkInDate1).at(firsServicePointId));
    mockClockManagerToReturnFixedDateTime(checkInDate2);
    checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate2).at(firsServicePointId));
    List<JsonObject> items = ResourceClient.forItemsInTransitReport().getAll();
    assertThat(items.size(), is(2));
    JsonObject firstItemJson = getRecordById(items, smallAngryPlanet.getId()).get();
    verifyItem(firstItemJson, smallAngryPlanet, secondServicePointId);
    verifyLocation(firstItemJson);
    verifyRequestWithSecondPickupServicePoint(firstItemJson, requestDate1, requestExpirationDate1);
    verifyLoanInFirstServicePoint(firstItemJson, checkInDate1);
    verifyLastCheckIn(firstItemJson, checkInDate1, SERVICE_POINT_NAME_1);
    JsonObject secondItemJson = getRecordById(items, nod.getId()).get();
    verifyItem(secondItemJson, nod, secondServicePointId);
    verifyLocation(secondItemJson);
    verifyRequest(secondItemJson, requestDate2, requestExpirationDate2, SERVICE_POINT_NAME_2);
    verifyLoanInFirstServicePoint(secondItemJson, checkInDate2);
    verifyLastCheckIn(secondItemJson, checkInDate2, SERVICE_POINT_NAME_1);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test)

Example 12 with ItemResource

use of api.support.http.ItemResource in project mod-circulation by folio-org.

the class ItemsInTransitReportTests method reportExcludesItemsThatAreNotInTransit.

@Test
void reportExcludesItemsThatAreNotInTransit() {
    final ItemResource smallAngryPlanet = createSmallAngryPlanet();
    final ItemResource nod = createNod();
    final ZonedDateTime checkInDate = ZonedDateTime.of(2019, 8, 13, 5, 0, 0, 0, UTC);
    final ZonedDateTime requestDate = ZonedDateTime.of(2019, 7, 5, 10, 0, 0, 0, UTC);
    final LocalDate requestExpirationDate = LocalDate.of(2019, 7, 11);
    final IndividualResource steve = usersFixture.steve();
    final UUID firstServicePointId = servicePointsFixture.cd1().getId();
    final UUID secondServicePointId = servicePointsFixture.cd2().getId();
    checkOutFixture.checkOutByBarcode(smallAngryPlanet);
    checkOutFixture.checkOutByBarcode(nod);
    createRequest(smallAngryPlanet, steve, secondServicePointId, requestDate, requestExpirationDate);
    mockClockManagerToReturnFixedDateTime(checkInDate);
    checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(smallAngryPlanet).on(checkInDate).at(firstServicePointId));
    List<JsonObject> items = ResourceClient.forItemsInTransitReport().getAll();
    assertThat(items.size(), is(1));
    JsonObject itemJson = items.get(0);
    verifyItem(itemJson, smallAngryPlanet, secondServicePointId);
    verifyLocation(itemJson);
    verifyRequestWithSecondPickupServicePoint(itemJson, requestDate, requestExpirationDate);
    verifyLoanInFirstServicePoint(itemJson, checkInDate);
    verifyLastCheckIn(itemJson, checkInDate, SERVICE_POINT_NAME_1);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) LocalDate(java.time.LocalDate) Test(org.junit.jupiter.api.Test)

Example 13 with ItemResource

use of api.support.http.ItemResource in project mod-circulation by folio-org.

the class PickSlipsTests method responseContainsNoPickSlipsForWrongServicePointId.

@Test
void responseContainsNoPickSlipsForWrongServicePointId() {
    UUID servicePointId = servicePointsFixture.cd1().getId();
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
    requestsFixture.place(new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(servicePointId).forItem(item).by(usersFixture.james()));
    UUID differentServicePointId = servicePointsFixture.cd2().getId();
    Response response = ResourceClient.forPickSlips().getById(differentServicePointId);
    assertThat(response.getStatusCode(), is(HTTP_OK));
    assertResponseHasItems(response, 0);
}
Also used : Response(org.folio.circulation.support.http.client.Response) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Example 14 with ItemResource

use of api.support.http.ItemResource in project mod-circulation by folio-org.

the class RequestsAPICreationTests method canCreateTlrRecallForInstanceWithSingleItemAndTwoLoans.

@Test
void canCreateTlrRecallForInstanceWithSingleItemAndTwoLoans() {
    reconfigureTlrFeature(TlrFeatureStatus.ENABLED);
    final ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
    final IndividualResource requestPickupServicePoint = servicePointsFixture.cd1();
    IndividualResource initialLoan = checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    checkInFixture.checkInByBarcode(item);
    IndividualResource dueDateChangeLoan = checkOutFixture.checkOutByBarcode(item, usersFixture.jessica());
    requestsClient.create(new RequestBuilder().recall().withNoHoldingsRecordId().withNoItemId().titleRequestLevel().withInstanceId(item.getInstanceId()).withPickupServicePointId(requestPickupServicePoint.getId()).withRequesterId(usersFixture.james().getId()));
    PublishedEvents publishedEvents = Awaitility.await().atMost(1, TimeUnit.SECONDS).until(FakePubSub::getPublishedEvents, hasSize(9));
    JsonObject loanWithoutChange = loansClient.get(initialLoan.getId()).getJson();
    assertNull(loanWithoutChange.getString("dueDateChangedByRecall"));
    JsonObject updatedLoan = loansClient.get(dueDateChangeLoan.getId()).getJson();
    assertThat(updatedLoan.getString("dueDateChangedByRecall"), true);
    JsonObject event = publishedEvents.findFirst(byEventType("LOAN_DUE_DATE_CHANGED"));
    assertThat(event, isValidLoanDueDateChangedEvent(updatedLoan));
    assertThat(new JsonObject(event.getString("eventPayload")).getBoolean("dueDateChangedByRecall"), equalTo(true));
}
Also used : FakePubSub(api.support.fakes.FakePubSub) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) PublishedEvents(api.support.fakes.PublishedEvents) PatronNoticeTestHelper.verifyNumberOfPublishedEvents(api.support.utl.PatronNoticeTestHelper.verifyNumberOfPublishedEvents) JsonObject(io.vertx.core.json.JsonObject) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 15 with ItemResource

use of api.support.http.ItemResource in project mod-circulation by folio-org.

the class RequestsAPICreationTests method cannotCreateRequestWithNonExistentRequestLevel.

@Test
void cannotCreateRequestWithNonExistentRequestLevel() {
    UUID patronId = usersFixture.charlotte().getId();
    final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
    UUID instanceId = item.getInstanceId();
    Response postResponse = requestsClient.attemptCreate(new RequestBuilder().recall().withItemId(item.getId()).withRequestLevel("invalid").withInstanceId(instanceId).withPickupServicePointId(pickupServicePointId).withRequesterId(patronId));
    assertThat(postResponse, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(postResponse.getJson(), hasErrorWith(allOf(hasMessage("requestLevel must be one of the following: \"Item\""), hasParameter("requestLevel", "invalid"))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) MoveRequestBuilder(api.support.builders.MoveRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

ItemResource (api.support.http.ItemResource)232 Test (org.junit.jupiter.api.Test)218 IndividualResource (api.support.http.IndividualResource)189 JsonObject (io.vertx.core.json.JsonObject)138 UUID (java.util.UUID)127 RequestBuilder (api.support.builders.RequestBuilder)117 Response (org.folio.circulation.support.http.client.Response)89 ZonedDateTime (java.time.ZonedDateTime)81 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)61 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)40 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)39 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)38 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)36 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)32 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)27 ItemBuilder (api.support.builders.ItemBuilder)21 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)13 UserResource (api.support.http.UserResource)13 HashMap (java.util.HashMap)13 Matcher (org.hamcrest.Matcher)13