Search in sources :

Example 6 with RequestBuilder

use of api.support.builders.RequestBuilder 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 7 with RequestBuilder

use of api.support.builders.RequestBuilder in project mod-circulation by folio-org.

the class PickSlipsTests method responseContainsPickSlipsWhenServicePointHasManyLocations.

@Test
void responseContainsPickSlipsWhenServicePointHasManyLocations() {
    final UUID servicePointId = servicePointsFixture.cd1().getId();
    final int numberOfLocations = 100;
    IndividualResource location = null;
    for (int i = 0; i < numberOfLocations; i++) {
        final int currentIndex = i;
        location = locationsFixture.basedUponExampleLocation(builder -> builder.withName("Test location " + currentIndex).withCode("LOC_" + currentIndex).withPrimaryServicePoint(servicePointId));
    }
    val lastLocation = location;
    val item = itemsFixture.basedUponSmallAngryPlanet(builder -> builder.withPermanentLocation(lastLocation.getId()).withNoTemporaryLocation());
    val james = usersFixture.james();
    RequestBuilder pageRequestBuilder = new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(servicePointId).forItem(item).by(james);
    val pageRequest = requestsClient.create(pageRequestBuilder);
    val response = ResourceClient.forPickSlips().getById(servicePointId);
    assertThat(response.getStatusCode(), is(HTTP_OK));
    assertResponseHasItems(response, 1);
    assertResponseContains(response, item, pageRequest, james);
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) Arrays(java.util.Arrays) Location(org.folio.circulation.domain.Location) Response(org.folio.circulation.support.http.client.Response) JsonPropertyFetcher.getDateTimeProperty(org.folio.circulation.support.json.JsonPropertyFetcher.getDateTimeProperty) ZonedDateTime(java.time.ZonedDateTime) APITests(api.support.APITests) RequestBuilder(api.support.builders.RequestBuilder) ItemStatus(org.folio.circulation.domain.ItemStatus) Item(org.folio.circulation.domain.Item) HTTP_OK(java.net.HttpURLConnection.HTTP_OK) IndividualResource(api.support.http.IndividualResource) Address(api.support.builders.Address) Is.is(org.hamcrest.core.Is.is) TextDateTimeMatcher.isEquivalentTo(api.support.matchers.TextDateTimeMatcher.isEquivalentTo) JsonObject(io.vertx.core.json.JsonObject) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ZoneOffset(java.time.ZoneOffset) JsonObjectArrayPropertyFetcher(org.folio.circulation.support.json.JsonObjectArrayPropertyFetcher) InstanceMapper(org.folio.circulation.storage.mappers.InstanceMapper) lombok.val(lombok.val) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) User(org.folio.circulation.domain.User) CallNumberComponents(org.folio.circulation.domain.CallNumberComponents) Test(org.junit.jupiter.api.Test) UserResource(api.support.http.UserResource) List(java.util.List) Stream(java.util.stream.Stream) ClockUtil(org.folio.circulation.support.utils.ClockUtil) ResourceClient(api.support.http.ResourceClient) UUIDMatcher(api.support.matchers.UUIDMatcher) LocalDate(java.time.LocalDate) RequestStatus(org.folio.circulation.domain.RequestStatus) UTC(java.time.ZoneOffset.UTC) AddressExamples(api.support.fixtures.AddressExamples) JsonPropertyFetcher.getNestedStringProperty(org.folio.circulation.support.json.JsonPropertyFetcher.getNestedStringProperty) lombok.val(lombok.val) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Example 8 with RequestBuilder

use of api.support.builders.RequestBuilder in project mod-circulation by folio-org.

the class PickSlipsTests method responseIncludesItemsFromDifferentLocationsForSameServicePoint.

@Test
void responseIncludesItemsFromDifferentLocationsForSameServicePoint() {
    UUID circDesk1 = servicePointsFixture.cd1().getId();
    // Circ desk 1: Second floor
    val secondFloorCd1 = locationsFixture.secondFloorEconomics();
    val temeraireSecondFloorCd1 = itemsFixture.basedUponTemeraire(holdingBuilder -> holdingBuilder.withPermanentLocation(secondFloorCd1).withNoTemporaryLocation(), itemBuilder -> itemBuilder.withNoPermanentLocation().withNoTemporaryLocation());
    val james = usersFixture.james();
    val temeraireRequest = requestsFixture.place(new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(circDesk1).forItem(temeraireSecondFloorCd1).by(james));
    // Circ desk 1: Third floor
    val thirdFloorCd1 = locationsFixture.thirdFloor();
    val planetThirdFloorCd1 = itemsFixture.basedUponSmallAngryPlanet(holdingBuilder -> holdingBuilder.withPermanentLocation(thirdFloorCd1).withNoTemporaryLocation(), itemBuilder -> itemBuilder.withNoPermanentLocation().withNoTemporaryLocation());
    val charlotte = usersFixture.charlotte();
    val planetRequest = requestsFixture.place(new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(circDesk1).forItem(planetThirdFloorCd1).by(charlotte));
    val response = ResourceClient.forPickSlips().getById(circDesk1);
    assertThat(response.getStatusCode(), is(HTTP_OK));
    assertResponseHasItems(response, 2);
    assertResponseContains(response, temeraireSecondFloorCd1, temeraireRequest, james);
    assertResponseContains(response, planetThirdFloorCd1, planetRequest, charlotte);
}
Also used : lombok.val(lombok.val) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 9 with RequestBuilder

use of api.support.builders.RequestBuilder in project mod-circulation by folio-org.

the class PickSlipsTests method responseDoesNotIncludePickSlipsFromDifferentServicePoint.

@Test
void responseDoesNotIncludePickSlipsFromDifferentServicePoint() {
    UUID circDesk1 = servicePointsFixture.cd1().getId();
    UUID circDesk4 = servicePointsFixture.cd4().getId();
    // Circ desk 1: Third floor
    val thirdFloorCd1 = locationsFixture.thirdFloor();
    val planetThirdFloorCd1 = itemsFixture.basedUponSmallAngryPlanet(holdingBuilder -> holdingBuilder.withPermanentLocation(thirdFloorCd1).withNoTemporaryLocation(), itemBuilder -> itemBuilder.withNoPermanentLocation().withNoTemporaryLocation());
    val charlotte = usersFixture.charlotte();
    val requestForThirdFloorCd1 = requestsFixture.place(new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(circDesk1).forItem(planetThirdFloorCd1).by(charlotte));
    // Circ desk 4: Second floor
    val secondFloorCd4 = locationsFixture.fourthServicePoint();
    val planetSecondFloorCd4 = itemsFixture.basedUponSmallAngryPlanet(holdingBuilder -> holdingBuilder.withPermanentLocation(secondFloorCd4).withNoTemporaryLocation(), itemBuilder -> itemBuilder.withNoPermanentLocation().withNoTemporaryLocation());
    val jessica = usersFixture.jessica();
    val requestForSecondFloorCd4 = requestsFixture.place(new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(circDesk1).forItem(planetSecondFloorCd4).by(jessica));
    // response for Circ Desk 1
    val responseForCd1 = ResourceClient.forPickSlips().getById(circDesk1);
    assertThat(responseForCd1.getStatusCode(), is(HTTP_OK));
    assertResponseHasItems(responseForCd1, 1);
    assertResponseContains(responseForCd1, planetThirdFloorCd1, requestForThirdFloorCd1, charlotte);
    // response for Circ Desk 4
    val responseForCd4 = ResourceClient.forPickSlips().getById(circDesk4);
    assertThat(responseForCd4.getStatusCode(), is(HTTP_OK));
    assertResponseHasItems(responseForCd4, 1);
    assertResponseContains(responseForCd4, planetSecondFloorCd4, requestForSecondFloorCd4, jessica);
}
Also used : lombok.val(lombok.val) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 10 with RequestBuilder

use of api.support.builders.RequestBuilder in project mod-circulation by folio-org.

the class PickSlipsTests method responseContainsNoPickSlipsForWrongServicePointId.

@Test
void responseContainsNoPickSlipsForWrongServicePointId() {
    UUID servicePointId = servicePointsFixture.cd1().getId();
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
    requestsFixture.place(new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(servicePointId).forItem(item).by(usersFixture.james()));
    UUID differentServicePointId = servicePointsFixture.cd2().getId();
    Response response = ResourceClient.forPickSlips().getById(differentServicePointId);
    assertThat(response.getStatusCode(), is(HTTP_OK));
    assertResponseHasItems(response, 0);
}
Also used : Response(org.folio.circulation.support.http.client.Response) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Test(org.junit.jupiter.api.Test)

Aggregations

RequestBuilder (api.support.builders.RequestBuilder)269 Test (org.junit.jupiter.api.Test)244 IndividualResource (api.support.http.IndividualResource)212 UUID (java.util.UUID)134 JsonObject (io.vertx.core.json.JsonObject)127 Response (org.folio.circulation.support.http.client.Response)124 ItemResource (api.support.http.ItemResource)117 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)113 MoveRequestBuilder (api.support.builders.MoveRequestBuilder)89 ZonedDateTime (java.time.ZonedDateTime)77 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)53 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)43 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)37 LoanPolicyBuilder (api.support.builders.LoanPolicyBuilder)34 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)28 ItemBuilder (api.support.builders.ItemBuilder)19 lombok.val (lombok.val)17 CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)10 MultipleJsonRecords (api.support.MultipleJsonRecords)9 Address (api.support.builders.Address)9