use of api.support.http.UserResource 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.UserResource 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.UserResource in project mod-circulation by folio-org.
the class CheckOutByBarcodeTests method failedCheckOutWithMultipleValidationErrors.
@Test
void failedCheckOutWithMultipleValidationErrors() {
final IndividualResource smallAngryPlanet = itemsFixture.basedUponSmallAngryPlanet();
final UserResource steve = usersFixture.steve();
loanPoliciesFixture.create(new LoanPolicyBuilder().withId(UUID.randomUUID()).withName("Example loan policy").withLoanable(true));
checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(smallAngryPlanet).to(steve).on(getZonedDateTime()).at(UUID.randomUUID()));
usersFixture.remove(steve);
final Response secondCheckoutResponse = checkOutFixture.attemptCheckOutByBarcode(smallAngryPlanet, steve);
assertThat(secondCheckoutResponse.getJson(), hasErrorWith(allOf(hasMessage("Could not find user with matching barcode"), hasUserBarcodeParameter(steve))));
assertThat(secondCheckoutResponse.getJson(), hasErrorWith(allOf(hasMessage("Item is already checked out"), hasItemBarcodeParameter(smallAngryPlanet))));
assertThat(secondCheckoutResponse.getJson(), hasErrorWith(allOf(hasMessage("Cannot check out item that already has an open loan"), hasItemBarcodeParameter(smallAngryPlanet))));
}
use of api.support.http.UserResource in project mod-circulation by folio-org.
the class PatronActionSessionTests method checkInSessionWithNonExistentUserShouldBeEnded.
@Test
void checkInSessionWithNonExistentUserShouldBeEnded() {
UserResource steve = usersFixture.steve();
ItemResource nod = itemsFixture.basedUponNod();
UUID checkInServicePointId = servicePointsFixture.cd1().getId();
checkOutFixture.checkOutByBarcode(nod, steve);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(checkInServicePointId));
verifyNumberOfExistingActionSessions(1, CHECK_IN);
usersFixture.remove(steve);
endPatronSessionClient.endCheckInSession(steve.getId());
verifyNumberOfExistingActionSessions(0, CHECK_IN);
verifyNumberOfSentNotices(0);
verifyNumberOfPublishedEvents(NOTICE, 0);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 1);
}
use of api.support.http.UserResource in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method requestAwaitingPickupNoticeIsNotSentWhenUserWasNotFound.
@Test
void requestAwaitingPickupNoticeIsNotSentWhenUserWasNotFound() {
JsonObject availableNoticeConfig = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withAvailableEvent().create();
NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with available notice").withLoanNotices(Collections.singletonList(availableNoticeConfig));
use(noticePolicy);
ItemResource requestedItem = itemsFixture.basedUponNod();
UUID pickupServicePointId = servicePointsFixture.cd1().getId();
ZonedDateTime requestDate = ZonedDateTime.of(2019, 10, 9, 10, 0, 0, 0, UTC);
UserResource steve = usersFixture.steve();
requestsFixture.place(new RequestBuilder().page().forItem(requestedItem).by(steve).withPickupServicePointId(pickupServicePointId).withRequestDate(requestDate));
ZonedDateTime checkInDate = ZonedDateTime.of(2019, 10, 10, 12, 30, 0, 0, UTC);
usersClient.delete(steve);
checkInFixture.checkInByBarcode(requestedItem, checkInDate, pickupServicePointId);
verifyNumberOfSentNotices(0);
verifyNumberOfPublishedEvents(NOTICE, 0);
verifyNumberOfPublishedEvents(NOTICE_ERROR, 1);
}
Aggregations