Search in sources :

Example 1 with ItemResource

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);
}
Also used : IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource)

Example 2 with ItemResource

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());
}
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) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 3 with ItemResource

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);
}
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 4 with ItemResource

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());
}
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 5 with ItemResource

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);
}
Also used : IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

ItemResource (api.support.http.ItemResource)232 Test (org.junit.jupiter.api.Test)218 IndividualResource (api.support.http.IndividualResource)189 JsonObject (io.vertx.core.json.JsonObject)138 UUID (java.util.UUID)127 RequestBuilder (api.support.builders.RequestBuilder)117 Response (org.folio.circulation.support.http.client.Response)89 ZonedDateTime (java.time.ZonedDateTime)81 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)61 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)40 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)39 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)38 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)36 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)32 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)27 ItemBuilder (api.support.builders.ItemBuilder)21 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)13 UserResource (api.support.http.UserResource)13 HashMap (java.util.HashMap)13 Matcher (org.hamcrest.Matcher)13