use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class ItemsFixture method create.
private ItemResource create(InstanceBuilder instanceBuilder, HoldingBuilder holdingsRecordBuilder, ItemBuilder itemBuilder) {
IndividualResource instance = instancesClient.create(instanceBuilder.withInstanceTypeId(booksInstanceTypeId()));
IndividualResource holding = holdingsClient.create(holdingsRecordBuilder.forInstance(instance.getId()));
final IndividualResource item = itemsClient.create(itemBuilder.forHolding(holding.getId()).create());
return new ItemResource(item, holding, instance);
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canCheckoutItemWhenTitleLevelPageRequestsExistForDifferentItemsOfSameInstance.
@Test
void canCheckoutItemWhenTitleLevelPageRequestsExistForDifferentItemsOfSameInstance() {
configurationsFixture.enableTlrFeature();
List<ItemResource> items = itemsFixture.createMultipleItemsForTheSameInstance(4);
UUID instanceId = items.stream().findAny().orElseThrow().getInstanceId();
List<String> pagedItemIds = Stream.of(requestsFixture.placeTitleLevelPageRequest(instanceId, usersFixture.steve()), requestsFixture.placeTitleLevelPageRequest(instanceId, usersFixture.jessica()), requestsFixture.placeTitleLevelPageRequest(instanceId, usersFixture.charlotte())).map(IndividualResource::getJson).map(json -> json.getString("itemId")).collect(Collectors.toList());
ItemResource nonPagedItem = items.stream().filter(not(item -> pagedItemIds.contains(item.getId().toString()))).findFirst().orElseThrow(() -> new AssertionError("Failed to find non-paged item"));
checkOutFixture.checkOutByBarcode(nonPagedItem, usersFixture.james());
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method titleLevelRequestIsIgnoredWhenTlrFeatureIsNotEnabled.
@ParameterizedTest
@EnumSource(value = TlrFeatureStatus.class, names = { "DISABLED", "NOT_CONFIGURED" })
void titleLevelRequestIsIgnoredWhenTlrFeatureIsNotEnabled(TlrFeatureStatus tlrFeatureStatus) {
configurationsFixture.enableTlrFeature();
ItemResource item = itemsFixture.basedUponNod();
UserResource borrower = usersFixture.steve();
UserResource requester = usersFixture.james();
requestsClient.create(new RequestBuilder().page().titleRequestLevel().withNoItemId().withNoHoldingsRecordId().withInstanceId(item.getInstanceId()).withPickupServicePointId(servicePointsFixture.cd1().getId()).withRequesterId(requester.getId()));
reconfigureTlrFeature(tlrFeatureStatus);
checkOutFixture.checkOutByBarcode(item, borrower);
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canFulfilPageAndHoldRequestsWithMixedLevels.
@ParameterizedTest
@CsvSource({ "Item, Item", "Item, Title", "Title, Item", "Title, Title" })
void canFulfilPageAndHoldRequestsWithMixedLevels(String pageRequestLevel, String holdRequestLevel) {
configurationsFixture.enableTlrFeature();
ItemResource item = itemsFixture.basedUponNod();
UserResource firstRequester = usersFixture.steve();
UserResource secondRequester = usersFixture.james();
final UUID pickupServicePointId = servicePointsFixture.cd1().getId();
UUID instanceId = item.getInstanceId();
UUID pageRequestItemId = "Item".equals(pageRequestLevel) ? item.getId() : null;
UUID pageRequestHoldingsRecordId = "Item".equals(pageRequestLevel) ? item.getHoldingsRecordId() : null;
UUID holdRequestItemId = "Item".equals(holdRequestLevel) ? item.getId() : null;
UUID holdRequestHoldingsRecordId = "Item".equals(holdRequestLevel) ? item.getHoldingsRecordId() : null;
IndividualResource pageRequest = requestsClient.create(new RequestBuilder().page().withRequestLevel(pageRequestLevel).withItemId(pageRequestItemId).withHoldingsRecordId(pageRequestHoldingsRecordId).withInstanceId(instanceId).withPickupServicePointId(pickupServicePointId).withRequesterId(firstRequester.getId()));
assertThat(pageRequest.getJson(), hasPosition(1));
assertThat(fetchItemJson(item), isPaged());
IndividualResource holdRequest = requestsClient.create(new RequestBuilder().hold().withRequestLevel(holdRequestLevel).withItemId(holdRequestItemId).withHoldingsRecordId(holdRequestHoldingsRecordId).withInstanceId(instanceId).withPickupServicePointId(pickupServicePointId).withRequesterId(secondRequester.getId()));
assertThat(holdRequest.getJson(), hasPosition(2));
checkInFixture.checkInByBarcode(item);
assertThat(fetchItemJson(item), isAwaitingPickup());
assertThat(fetchRequestJson(pageRequest), isOpenAwaitingPickup());
// fulfil page request
checkOutFixture.checkOutByBarcode(item, firstRequester);
assertThat(fetchItemJson(item), isCheckedOut());
assertThat(fetchRequestJson(pageRequest), isClosedFilled());
// check the item back in
checkInFixture.checkInByBarcode(item);
assertThat(fetchItemJson(item), isAwaitingPickup());
assertThat(fetchRequestJson(holdRequest), isOpenAwaitingPickup());
assertThat(fetchRequestJson(holdRequest), hasPosition(1));
// fulfil hold request
checkOutFixture.checkOutByBarcode(item, secondRequester);
assertThat(fetchItemJson(item), isCheckedOut());
assertThat(fetchRequestJson(holdRequest), isClosedFilled());
}
use of api.support.http.ItemResource in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method canCheckOutWhenItemLimitIsIgnoredForRulesWithoutMaterialTypeOrLoanType.
@Test
void canCheckOutWhenItemLimitIsIgnoredForRulesWithoutMaterialTypeOrLoanType() {
useFallbackPolicies(prepareLoanPolicyWithItemLimit(1).getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.inactiveNotice().getId(), overdueFinePoliciesFixture.facultyStandard().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
ItemResource firstItem = itemsFixture.basedUponNod();
ItemResource secondItem = itemsFixture.basedUponDunkirk();
IndividualResource steve = usersFixture.steve();
checkOutFixture.checkOutByBarcode(firstItem, steve);
checkOutFixture.checkOutByBarcode(secondItem, steve);
}
Aggregations