Search in sources :

Example 1 with UserResource

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);
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) UserResource(api.support.http.UserResource) ItemResource(api.support.http.ItemResource) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with UserResource

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());
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) UserResource(api.support.http.UserResource) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with UserResource

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))));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) UserResource(api.support.http.UserResource) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) IndividualResource(api.support.http.IndividualResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 4 with UserResource

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);
}
Also used : UserResource(api.support.http.UserResource) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Example 5 with UserResource

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);
}
Also used : CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) UserResource(api.support.http.UserResource) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Aggregations

UserResource (api.support.http.UserResource)15 ItemResource (api.support.http.ItemResource)12 UUID (java.util.UUID)12 Test (org.junit.jupiter.api.Test)12 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)7 RequestBuilder (api.support.builders.RequestBuilder)7 ZonedDateTime (java.time.ZonedDateTime)7 IndividualResource (api.support.http.IndividualResource)6 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)5 JsonObject (io.vertx.core.json.JsonObject)5 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)4 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)4 Response (org.folio.circulation.support.http.client.Response)4 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)2 UserBuilder (api.support.builders.UserBuilder)2 OkapiHeaders (api.support.http.OkapiHeaders)2 RequestsAPICreationTests.setupMissingItem (api.requests.RequestsAPICreationTests.setupMissingItem)1 END_OF_CURRENT_YEAR_DUE_DATE (api.support.APITestContext.END_OF_CURRENT_YEAR_DUE_DATE)1