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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations