Search in sources :

Example 6 with UserResource

use of api.support.http.UserResource in project mod-circulation by folio-org.

the class CheckOutByBarcodeTests method cannotCheckoutItemWhenTitleLevelPageRequestExistsForSameItem.

@ParameterizedTest
@CsvSource({ "Item, Item", "Item, Title", "Title, Item", "Title, Title" })
void cannotCheckoutItemWhenTitleLevelPageRequestExistsForSameItem(String firstRequestLevel, String secondRequestLevel) {
    configurationsFixture.enableTlrFeature();
    List<ItemResource> items = itemsFixture.createMultipleItemsForTheSameInstance(2);
    ItemResource randomItem = items.stream().findAny().orElseThrow();
    IndividualResource firstRequest = placeRequest(firstRequestLevel, randomItem, usersFixture.steve());
    String requestedItemId = firstRequest.getJson().getString("itemId");
    // If first request level is Title, the item for it is selected randomly among Available items
    // of the instance. So for second request we have to find the other (Available) item.
    ItemResource itemForSecondRequest = items.stream().filter(not(item -> item.getId().toString().equals(requestedItemId))).findAny().orElseThrow(() -> new AssertionError("Failed to find non-requested item"));
    placeRequest(secondRequestLevel, itemForSecondRequest, usersFixture.jessica());
    UserResource borrower = usersFixture.james();
    Response response = checkOutFixture.attemptCheckOutByBarcode(itemForSecondRequest, borrower);
    assertThat(response.getStatusCode(), is(422));
    assertThat(response.getJson(), hasErrorWith(allOf(hasUserBarcodeParameter(borrower), hasMessage(String.format("The Long Way to a Small, Angry Planet (Barcode: %s) cannot be checked out to user " + "Rodwell, James because it has been requested by another patron", itemForSecondRequest.getBarcode())))));
}
Also used : ResponseStatusCodeMatcher.hasStatus(api.support.matchers.ResponseStatusCodeMatcher.hasStatus) CheckOutByBarcodeResponseMatchers.hasUserBarcodeParameter(api.support.matchers.CheckOutByBarcodeResponseMatchers.hasUserBarcodeParameter) ZonedDateTime(java.time.ZonedDateTime) FakePubSub(api.support.fakes.FakePubSub) EventMatchers.isValidCheckOutLogEvent(api.support.matchers.EventMatchers.isValidCheckOutLogEvent) DateFormatUtil.parseDateTime(org.folio.circulation.support.utils.DateFormatUtil.parseDateTime) CASE_FIRST_DAY_OPEN_SECOND_CLOSED_THIRD_OPEN(api.support.fixtures.CalendarExamples.CASE_FIRST_DAY_OPEN_SECOND_CLOSED_THIRD_OPEN) RequestMatchers.hasPosition(api.support.matchers.RequestMatchers.hasPosition) Matchers.nullValue(org.hamcrest.Matchers.nullValue) CLAIMED_RETURNED(api.support.builders.ItemBuilder.CLAIMED_RETURNED) ItemMatchers.isLostAndPaid(api.support.matchers.ItemMatchers.isLostAndPaid) JsonObject(io.vertx.core.json.JsonObject) CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) MAX_OUTSTANDING_FEE_FINE_BALANCE_MESSAGE(api.support.fixtures.AutomatedPatronBlocksFixture.MAX_OUTSTANDING_FEE_FINE_BALANCE_MESSAGE) ItemMatchers.isWithdrawn(api.support.matchers.ItemMatchers.isWithdrawn) MOVE_TO_THE_END_OF_THE_NEXT_OPEN_DAY(org.folio.circulation.domain.policy.DueDateManagement.MOVE_TO_THE_END_OF_THE_NEXT_OPEN_DAY) DateTimeUtil.atStartOfDay(org.folio.circulation.support.utils.DateTimeUtil.atStartOfDay) ItemNotLoanableBlockOverrideBuilder(api.support.builders.ItemNotLoanableBlockOverrideBuilder) SECOND_DAY_CLOSED(api.support.fixtures.CalendarExamples.SECOND_DAY_CLOSED) CHECK_OUT(org.folio.circulation.domain.representations.logs.LogEventType.CHECK_OUT) FixedDueDateSchedule(api.support.builders.FixedDueDateSchedule) ItemMatchers.isCheckedOut(api.support.matchers.ItemMatchers.isCheckedOut) Stream(java.util.stream.Stream) BlockOverridesUtils.getMissingPermissions(api.support.utl.BlockOverridesUtils.getMissingPermissions) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Predicate.not(java.util.function.Predicate.not) Awaitility(org.awaitility.Awaitility) HTTP_UNPROCESSABLE_ENTITY(org.folio.HttpStatus.HTTP_UNPROCESSABLE_ENTITY) LoanMatchers.isOpen(api.support.matchers.LoanMatchers.isOpen) ItemMatchers.isPaged(api.support.matchers.ItemMatchers.isPaged) KEEP_THE_CURRENT_DUE_DATE(org.folio.circulation.domain.policy.DueDateManagement.KEEP_THE_CURRENT_DUE_DATE) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) ValidationErrorMatchers.hasMessage(api.support.matchers.ValidationErrorMatchers.hasMessage) POST(io.vertx.core.http.HttpMethod.POST) ValidationErrorMatchers.hasUUIDParameter(api.support.matchers.ValidationErrorMatchers.hasUUIDParameter) ITEM_CHECKED_OUT(org.folio.circulation.domain.EventType.ITEM_CHECKED_OUT) ItemBuilder(api.support.builders.ItemBuilder) IndividualResource(api.support.http.IndividualResource) CHECKED_OUT(api.support.builders.ItemBuilder.CHECKED_OUT) TextDateTimeMatcher.isEquivalentTo(api.support.matchers.TextDateTimeMatcher.isEquivalentTo) Matchers.hasSize(org.hamcrest.Matchers.hasSize) FixedDueDateSchedulesBuilder(api.support.builders.FixedDueDateSchedulesBuilder) ItemStatusCodeMatcher.hasItemStatus(api.support.matchers.ItemStatusCodeMatcher.hasItemStatus) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CheckOutByBarcodeResponseMatchers.hasServicePointParameter(api.support.matchers.CheckOutByBarcodeResponseMatchers.hasServicePointParameter) LogEventType(org.folio.circulation.domain.representations.logs.LogEventType) DateTimeUtil.atEndOfDay(org.folio.circulation.support.utils.DateTimeUtil.atEndOfDay) RequestMatchers.isOpenAwaitingPickup(api.support.matchers.RequestMatchers.isOpenAwaitingPickup) lombok.val(lombok.val) UserBuilder(api.support.builders.UserBuilder) AVAILABLE(api.support.builders.ItemBuilder.AVAILABLE) EventMatchers.isValidItemCheckedOutEvent(api.support.matchers.EventMatchers.isValidItemCheckedOutEvent) ValidationErrorMatchers.hasErrorWith(api.support.matchers.ValidationErrorMatchers.hasErrorWith) JsonArray(io.vertx.core.json.JsonArray) MOVE_TO_BEGINNING_OF_NEXT_OPEN_SERVICE_POINT_HOURS(org.folio.circulation.domain.policy.DueDateManagement.MOVE_TO_BEGINNING_OF_NEXT_OPEN_SERVICE_POINT_HOURS) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ChronoUnit(java.time.temporal.ChronoUnit) MAX_NUMBER_OF_ITEMS_CHARGED_OUT_MESSAGE(api.support.fixtures.AutomatedPatronBlocksFixture.MAX_NUMBER_OF_ITEMS_CHARGED_OUT_MESSAGE) END_OF_CURRENT_YEAR_DUE_DATE(api.support.APITestContext.END_OF_CURRENT_YEAR_DUE_DATE) RequestMatchers.isClosedFilled(api.support.matchers.RequestMatchers.isClosedFilled) MOVE_TO_THE_END_OF_THE_PREVIOUS_OPEN_DAY(org.folio.circulation.domain.policy.DueDateManagement.MOVE_TO_THE_END_OF_THE_PREVIOUS_OPEN_DAY) CoreMatchers.is(org.hamcrest.CoreMatchers.is) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Response(org.folio.circulation.support.http.client.Response) CheckOutByBarcodeResponseMatchers.hasItemBarcodeParameter(api.support.matchers.CheckOutByBarcodeResponseMatchers.hasItemBarcodeParameter) LoanPolicyBuilder(api.support.builders.LoanPolicyBuilder) PublishedEvents.byEventType(api.support.fakes.PublishedEvents.byEventType) APITests(api.support.APITests) Random(java.util.Random) DateFormatUtil.formatDateTime(org.folio.circulation.support.utils.DateFormatUtil.formatDateTime) UUIDMatcher.is(api.support.matchers.UUIDMatcher.is) ItemMatchers.isAwaitingPickup(api.support.matchers.ItemMatchers.isAwaitingPickup) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Period.months(org.folio.circulation.domain.policy.Period.months) Period(org.folio.circulation.domain.policy.Period) PublishedEvents.byLogEventType(api.support.fakes.PublishedEvents.byLogEventType) LocalTime(java.time.LocalTime) JsonObjectMatcher.hasJsonPath(api.support.matchers.JsonObjectMatcher.hasJsonPath) UUID(java.util.UUID) MOVE_TO_END_OF_CURRENT_SERVICE_POINT_HOURS(org.folio.circulation.domain.policy.DueDateManagement.MOVE_TO_END_OF_CURRENT_SERVICE_POINT_HOURS) ItemResource(api.support.http.ItemResource) Collectors(java.util.stream.Collectors) CASE_MON_WED_FRI_OPEN_TUE_THU_CLOSED(api.support.fixtures.CalendarExamples.CASE_MON_WED_FRI_OPEN_TUE_THU_CLOSED) Test(org.junit.jupiter.api.Test) UserResource(api.support.http.UserResource) List(java.util.List) RequestsAPICreationTests.setupMissingItem(api.requests.RequestsAPICreationTests.setupMissingItem) CheckOutBlockOverrides(api.support.builders.CheckOutBlockOverrides) UTC(java.time.ZoneOffset.UTC) CheckOutByBarcodeResponseMatchers.hasProxyUserBarcodeParameter(api.support.matchers.CheckOutByBarcodeResponseMatchers.hasProxyUserBarcodeParameter) TextDateTimeMatcher.withinSecondsAfter(api.support.matchers.TextDateTimeMatcher.withinSecondsAfter) APITestContext.getOkapiHeadersFromContext(api.support.APITestContext.getOkapiHeadersFromContext) CsvSource(org.junit.jupiter.params.provider.CsvSource) CASE_FIRST_DAY_OPEN_SECOND_CLOSED_THIRD_CLOSED(api.support.fixtures.CalendarExamples.CASE_FIRST_DAY_OPEN_SECOND_CLOSED_THIRD_CLOSED) EnumSource(org.junit.jupiter.params.provider.EnumSource) RequestBuilder(api.support.builders.RequestBuilder) MONDAY_DATE(api.support.fixtures.CalendarExamples.MONDAY_DATE) OkapiHeaders(api.support.http.OkapiHeaders) ValidationErrorMatchers.hasParameter(api.support.matchers.ValidationErrorMatchers.hasParameter) END_TIME_SECOND_PERIOD(api.support.fixtures.CalendarExamples.END_TIME_SECOND_PERIOD) NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) CoreMatchers.allOf(org.hamcrest.CoreMatchers.allOf) FakeStorageModule(api.support.fakes.FakeStorageModule) FIRST_DAY_OPEN(api.support.fixtures.CalendarExamples.FIRST_DAY_OPEN) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) LoanBuilder(api.support.builders.LoanBuilder) CheckOutByBarcodeResponseMatchers.hasLoanPolicyParameters(api.support.matchers.CheckOutByBarcodeResponseMatchers.hasLoanPolicyParameters) CHECK_OUT_THROUGH_OVERRIDE(org.folio.circulation.domain.representations.logs.LogEventType.CHECK_OUT_THROUGH_OVERRIDE) TimeUnit(java.util.concurrent.TimeUnit) CALL_NUMBER_COMPONENTS(org.folio.circulation.domain.representations.ItemProperties.CALL_NUMBER_COMPONENTS) PubsubPublisherTestUtils.assertThatPublishedLoanLogRecordEventsAreValid(api.support.PubsubPublisherTestUtils.assertThatPublishedLoanLogRecordEventsAreValid) KEEP_THE_CURRENT_DUE_DATE_TIME(org.folio.circulation.domain.policy.DueDateManagement.KEEP_THE_CURRENT_DUE_DATE_TIME) TlrFeatureStatus(api.support.TlrFeatureStatus) HTTP_INTERNAL_SERVER_ERROR(org.folio.HttpStatus.HTTP_INTERNAL_SERVER_ERROR) DueDateManagement(org.folio.circulation.domain.policy.DueDateManagement) Response(org.folio.circulation.support.http.client.Response) UserResource(api.support.http.UserResource) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with UserResource

use of api.support.http.UserResource in project mod-circulation by folio-org.

the class CheckInByBarcodeTests method requestAwaitingPickupNoticeIsNotSentWhenPatronNoticeRequestsFails.

@Test
void requestAwaitingPickupNoticeIsNotSentWhenPatronNoticeRequestsFails() {
    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);
    FakeModNotify.setFailPatronNoticesWithBadRequest(true);
    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)

Example 8 with UserResource

use of api.support.http.UserResource in project mod-circulation by folio-org.

the class CheckInByBarcodeTests method patronNoticeIsSentForRequestAwaitingPickupWhenPreviousRequestWasClosed.

private void patronNoticeIsSentForRequestAwaitingPickupWhenPreviousRequestWasClosed(RequestStatus firstRequestUpdateStatus) {
    UUID requestAwaitingPickupTemplateId = UUID.randomUUID();
    UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    use(new NoticePolicyBuilder().withName("Policy with Request Awaiting Pickup notice").withLoanNotices(Collections.singletonList(new NoticeConfigurationBuilder().withTemplateId(requestAwaitingPickupTemplateId).withAvailableEvent().create())));
    ZonedDateTime requestDate = ZonedDateTime.of(2020, 11, 30, 13, 30, 0, 0, UTC);
    ZonedDateTime requestExpirationDateTime = requestDate.plusMonths(1);
    LocalDate requestExpirationDate = toLocalDate(requestExpirationDateTime);
    ZonedDateTime firstCheckInDate = requestDate.plusDays(1);
    ZonedDateTime secondCheckInDate = firstCheckInDate.plusDays(1);
    ItemResource item = itemsFixture.basedUponNod();
    // create two requests for the same item
    UserResource firstRequester = usersFixture.steve();
    IndividualResource firstRequest = requestsFixture.place(new RequestBuilder().page().forItem(item).by(firstRequester).withPickupServicePointId(pickupServicePointId).withRequestDate(requestDate).withRequestExpiration(requestExpirationDate).withHoldShelfExpiration(requestExpirationDate));
    UserResource secondRequester = usersFixture.james();
    IndividualResource secondRequest = requestsFixture.place(new RequestBuilder().hold().forItem(item).by(secondRequester).withPickupServicePointId(pickupServicePointId).withRequestDate(requestDate).withRequestExpiration(requestExpirationDate).withHoldShelfExpiration(requestExpirationDate));
    // verify that both requests are "Open - Not yet filled"
    assertThatRequestStatusIs(firstRequest.getId(), RequestStatus.OPEN_NOT_YET_FILLED);
    assertThatRequestStatusIs(secondRequest.getId(), RequestStatus.OPEN_NOT_YET_FILLED);
    // check the item in
    checkInFixture.checkInByBarcode(item, firstCheckInDate, pickupServicePointId);
    // check that both item and first request are awaiting pickup
    assertThatItemStatusIs(item.getId(), ItemStatus.AWAITING_PICKUP);
    assertThatRequestStatusIs(firstRequest.getId(), RequestStatus.OPEN_AWAITING_PICKUP);
    // verify that Request Awaiting Pickup notice was sent for first request
    verifyNumberOfSentNotices(1);
    verifyNumberOfPublishedEvents(NOTICE, 1);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
    checkPatronNoticeEvent(firstRequest, firstRequester, item, requestAwaitingPickupTemplateId);
    clearSentPatronNoticesAndPubsubEvents();
    // Check-in again and verify that same notice is not sent repeatedly
    checkInFixture.checkInByBarcode(item, firstCheckInDate, pickupServicePointId);
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
    switch(firstRequestUpdateStatus) {
        case CLOSED_CANCELLED:
            requestsFixture.cancelRequest(firstRequest);
            break;
        // for purposes of this test request position has to be changed manually
        case CLOSED_UNFILLED:
            requestsFixture.expireRequest(firstRequest);
            updateRequestPosition(secondRequest, 1);
            break;
        case CLOSED_PICKUP_EXPIRED:
            requestsFixture.expireRequestPickup(firstRequest);
            updateRequestPosition(secondRequest, 1);
            break;
        default:
            fail("Unsupported request status");
    }
    // verify that first request was closed, and that item is still awaiting pickup
    assertThatItemStatusIs(item.getId(), ItemStatus.AWAITING_PICKUP);
    assertThatRequestStatusIs(firstRequest.getId(), firstRequestUpdateStatus);
    // check the item in again
    checkInFixture.checkInByBarcode(item, secondCheckInDate, pickupServicePointId);
    // verify that item is still awaiting pickup, and that second request is now awaiting pickup
    assertThatItemStatusIs(item.getId(), ItemStatus.AWAITING_PICKUP);
    assertThatRequestStatusIs(secondRequest.getId(), RequestStatus.OPEN_AWAITING_PICKUP);
    // verify that Request Awaiting Pickup notice was sent to second requester
    verifyNumberOfSentNotices(1);
    verifyNumberOfPublishedEvents(NOTICE, 1);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
    checkPatronNoticeEvent(secondRequest, secondRequester, item, requestAwaitingPickupTemplateId);
    clearSentPatronNoticesAndPubsubEvents();
    // Check-in again and verify that same notice is not sent repeatedly
    checkInFixture.checkInByBarcode(item, secondCheckInDate, pickupServicePointId);
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
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) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) LocalDate(java.time.LocalDate) ItemResource(api.support.http.ItemResource)

Example 9 with UserResource

use of api.support.http.UserResource in project mod-circulation by folio-org.

the class CheckInByBarcodeTests method availableNoticeIsSentUponCheckInWhenRequesterBarcodeWasChanged.

@Test
void availableNoticeIsSentUponCheckInWhenRequesterBarcodeWasChanged() {
    UUID templateId = UUID.randomUUID();
    JsonObject availableNoticeConfig = new NoticeConfigurationBuilder().withTemplateId(templateId).withAvailableEvent().create();
    NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Test policy").withLoanNotices(Collections.singletonList(availableNoticeConfig));
    use(noticePolicy);
    ItemResource requestedItem = itemsFixture.basedUponNod();
    UUID pickupServicePointId = servicePointsFixture.cd1().getId();
    UserResource requester = usersFixture.steve();
    ZonedDateTime requestDate = ZonedDateTime.of(2019, 10, 9, 10, 0, 0, 0, UTC);
    requestsFixture.place(new RequestBuilder().page().forItem(requestedItem).by(requester).withPickupServicePointId(pickupServicePointId).withRequestDate(requestDate));
    ZonedDateTime checkInDate = ZonedDateTime.of(2019, 10, 10, 12, 30, 0, 0, UTC);
    JsonObject updatedRequesterJson = requester.getJson().put("barcode", "updated_barcode");
    usersClient.replace(requester.getId(), updatedRequesterJson);
    checkInFixture.checkInByBarcode(requestedItem, checkInDate, pickupServicePointId);
    verifyNumberOfSentNotices(1);
    verifyNumberOfPublishedEvents(NOTICE, 1);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
    assertThat(FakeModNotify.getFirstSentPatronNotice(), hasEmailNoticeProperties(requester.getId(), templateId, getUserContextMatchers(updatedRequesterJson)));
}
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)

Example 10 with UserResource

use of api.support.http.UserResource in project mod-circulation by folio-org.

the class RequestsAPICreationTests method shouldFailToOverridePatronBlockWhenUserHasNoPermissionsAndNonOverridableErrorOccurs.

@Test
void shouldFailToOverridePatronBlockWhenUserHasNoPermissionsAndNonOverridableErrorOccurs() {
    UserResource inactiveSteve = usersFixture.steve(UserBuilder::inactive);
    UUID userId = inactiveSteve.getId();
    userManualBlocksFixture.createRequestsManualPatronBlockForUser(userId);
    Response response = attemptCreateRequestThroughPatronBlockOverride(userId, buildOkapiHeadersWithPermissions(CREATE_REQUEST_PERMISSION));
    assertThat(response, hasStatus(HTTP_UNPROCESSABLE_ENTITY));
    assertThat(response.getJson(), hasErrors(2));
    assertThat(response.getJson(), hasErrorWith(allOf(hasMessage("Inactive users cannot make requests"), hasUUIDParameter("requesterId", userId))));
    assertThat(getErrorsFromResponse(response), hasItem(isInsufficientPermissionsToOverridePatronBlockError()));
}
Also used : Response(org.folio.circulation.support.http.client.Response) UserResource(api.support.http.UserResource) UUID(java.util.UUID) UserBuilder(api.support.builders.UserBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) 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