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