use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method cannotCheckOutWhenItemIsNotLoanable.
@Test
void cannotCheckOutWhenItemIsNotLoanable() {
IndividualResource notLoanablePolicy = loanPoliciesFixture.create(new LoanPolicyBuilder().withName("Not Loanable Policy").withLoanable(false));
useFallbackPolicies(notLoanablePolicy.getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.inactiveNotice().getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
ItemResource nod = itemsFixture.basedUponNod();
IndividualResource steve = usersFixture.steve();
Response response = checkOutFixture.attemptCheckOutByBarcode(nod, steve);
assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Item is not loanable"), hasItemBarcodeParameter(nod), hasLoanPolicyParameters(notLoanablePolicy))));
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class ItemsInTransitReportTests method reportIncludesItemInTransit.
@Test
void reportIncludesItemInTransit() {
final ItemResource smallAngryPlanet = createSmallAngryPlanet();
final IndividualResource steve = usersFixture.steve();
final UUID firstServicePointId = servicePointsFixture.cd1().getId();
final UUID secondServicePointId = servicePointsFixture.cd2().getId();
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);
checkOutFixture.checkOutByBarcode(smallAngryPlanet);
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 ItemsInTransitReportTests method reportItemsInTransitSortedByCheckInServicePoint.
@Test
void reportItemsInTransitSortedByCheckInServicePoint() {
final ItemResource smallAngryPlanet = createSmallAngryPlanet();
final ItemResource nod = createNod();
final ItemResource smallAngryPlanetWithFourthCheckInServicePoint = itemsFixture.basedUponSmallAngryPlanet(createSmallAngryPlanetItemBuilder().withBarcode("34"), itemsFixture.thirdFloorHoldings());
final IndividualResource steve = usersFixture.steve();
final IndividualResource rebecca = usersFixture.rebecca();
final UUID firstServicePointId = servicePointsFixture.cd1().getId();
final UUID secondServicePointId = servicePointsFixture.cd2().getId();
final UUID fourthServicePointId = servicePointsFixture.cd4().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 checkInDate3 = ZonedDateTime.of(2019, 10, 10, 3, 0, 0, 0, UTC);
final ZonedDateTime requestDate1 = ZonedDateTime.of(2019, 7, 5, 10, 0, 0, 0, UTC);
final ZonedDateTime requestDate2 = ZonedDateTime.of(2019, 10, 8, 11, 0, 0, 0, UTC);
final LocalDate requestExpirationDate1 = LocalDate.of(2019, 7, 11);
final LocalDate requestExpirationDate2 = LocalDate.of(2020, 1, 12);
checkOutFixture.checkOutByBarcode(smallAngryPlanet);
checkOutFixture.checkOutByBarcode(nod);
checkOutFixture.checkOutByBarcode(smallAngryPlanetWithFourthCheckInServicePoint);
createRequest(smallAngryPlanet, steve, firstServicePointId, requestDate1, requestExpirationDate1);
createRequest(nod, rebecca, secondServicePointId, requestDate2, requestExpirationDate2);
mockClockManagerToReturnFixedDateTime(checkInDate3);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(smallAngryPlanetWithFourthCheckInServicePoint).on(checkInDate3).at(fourthServicePointId));
mockClockManagerToReturnFixedDateTime(checkInDate2);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate2).at(firstServicePointId));
mockClockManagerToReturnFixedDateTime(checkInDate1);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(smallAngryPlanet).on(checkInDate1).at(secondServicePointId));
List<JsonObject> items = ResourceClient.forItemsInTransitReport().getAll();
assertThat(items.size(), is(3));
JsonObject firstItemJson = items.get(0);
verifyItem(firstItemJson, nod, secondServicePointId);
verifyLocation(firstItemJson);
verifyRequest(firstItemJson, requestDate2, requestExpirationDate2, SERVICE_POINT_NAME_2);
verifyLoanInFirstServicePoint(firstItemJson, checkInDate2);
verifyLastCheckIn(firstItemJson, checkInDate2, SERVICE_POINT_NAME_1);
JsonObject secondItemJson = items.get(1);
verifyItem(secondItemJson, smallAngryPlanet, firstServicePointId);
verifyLocation(secondItemJson);
verifyRequest(secondItemJson, requestDate1, requestExpirationDate1, SERVICE_POINT_NAME_1);
verifyLoan(secondItemJson, checkInDate1, SERVICE_POINT_NAME_2, SERVICE_POINT_CODE_2, "Circulation Desk -- Back Entrance");
verifyLastCheckIn(secondItemJson, checkInDate1, SERVICE_POINT_NAME_2);
JsonObject thirdItemJson = items.get(2);
verifyItem(thirdItemJson, smallAngryPlanetWithFourthCheckInServicePoint, firstServicePointId);
verifyLocation(thirdItemJson);
verifyLoan(thirdItemJson, checkInDate3, "Circ Desk 4", "cd4", "Circulation Desk -- Basement");
verifyLastCheckIn(thirdItemJson, checkInDate3, "Circ Desk 4");
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class ItemsInTransitReportTests method reportIncludesItemsInTransitWithMoreThanOneOpenRequestInQueue.
@Test
void reportIncludesItemsInTransitWithMoreThanOneOpenRequestInQueue() {
final ItemResource smallAngryPlanet = createSmallAngryPlanet();
final ItemResource nod = createNod();
final IndividualResource steve = usersFixture.steve();
final IndividualResource rebecca = usersFixture.rebecca();
final UUID firstServicePointId = 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 requestSmallAngryPlanetDate1 = ZonedDateTime.of(2019, 7, 5, 10, 0, 0, 0, UTC);
final ZonedDateTime requestSmallAngryPlanetDate2 = ZonedDateTime.of(2019, 10, 1, 12, 0, 0, 0, UTC);
final LocalDate requestSmallAngryPlanetExpirationDate1 = LocalDate.of(2019, 7, 11);
final LocalDate requestSmallAngryPlanetExpirationDate2 = LocalDate.of(2019, 11, 12);
final ZonedDateTime requestNodeDate1 = ZonedDateTime.of(2019, 5, 11, 1, 0, 0, 0, UTC);
final ZonedDateTime requestNodeDate2 = ZonedDateTime.of(2019, 10, 8, 11, 0, 0, 0, UTC);
final LocalDate requestNodeExpirationDate1 = LocalDate.of(2020, 1, 12);
final LocalDate requestNodeExpirationDate2 = LocalDate.of(2020, 10, 10);
checkOutFixture.checkOutByBarcode(smallAngryPlanet);
checkOutFixture.checkOutByBarcode(nod);
createRequest(smallAngryPlanet, steve, firstServicePointId, requestSmallAngryPlanetDate1, requestSmallAngryPlanetExpirationDate1);
createRequest(smallAngryPlanet, rebecca, firstServicePointId, requestSmallAngryPlanetDate2, requestSmallAngryPlanetExpirationDate2);
createRequest(nod, rebecca, secondServicePointId, requestNodeDate1, requestNodeExpirationDate1);
createRequest(nod, steve, secondServicePointId, requestNodeDate2, requestNodeExpirationDate2);
mockClockManagerToReturnFixedDateTime(checkInDate1);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(smallAngryPlanet).on(checkInDate1).at(secondServicePointId));
mockClockManagerToReturnFixedDateTime(checkInDate2);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate2).at(firstServicePointId));
List<JsonObject> items = ResourceClient.forItemsInTransitReport().getAll();
assertThat(items.size(), is(2));
JsonObject firstItemJson = getRecordById(items, smallAngryPlanet.getId()).get();
verifyItem(firstItemJson, smallAngryPlanet, firstServicePointId);
verifyLocation(firstItemJson);
verifyRequest(firstItemJson, requestSmallAngryPlanetDate1, requestSmallAngryPlanetExpirationDate1, SERVICE_POINT_NAME_1);
verifyLoan(firstItemJson, checkInDate1, SERVICE_POINT_NAME_2, SERVICE_POINT_CODE_2, "Circulation Desk -- Back Entrance");
verifyLastCheckIn(firstItemJson, checkInDate1, SERVICE_POINT_NAME_2);
JsonObject secondItemJson = getRecordById(items, nod.getId()).get();
verifyItem(secondItemJson, nod, secondServicePointId);
verifyLocation(secondItemJson);
verifyRequest(secondItemJson, requestNodeDate1, requestNodeExpirationDate1, 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 reportWillNotFailWithUriTooLargeError.
@Test
void reportWillNotFailWithUriTooLargeError() {
final UUID firstServicePointId = servicePointsFixture.cd1().getId();
final UUID forthServicePointLocationId = locationsFixture.fourthServicePoint().getId();
for (int i = 0; i < 200; i++) {
ItemResource item = createSmallAngryPlanetCopy(forthServicePointLocationId, Integer.toString(i));
checkOutFixture.checkOutByBarcode(item);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(item).on(ClockUtil.getZonedDateTime()).at(firstServicePointId));
}
List<JsonObject> itemsInTransitReport = ResourceClient.forItemsInTransitReport().getAll();
assertThat(itemsInTransitReport.size(), is(200));
}
Aggregations