use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method isNotPlacedInTransitWhenItemHasOpenFulfillableRequest.
@Test
void isNotPlacedInTransitWhenItemHasOpenFulfillableRequest() {
final IndividualResource primaryServicePoint = servicePointsFixture.cd1();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.getId()).withPrimaryServicePoint(primaryServicePoint.getId()));
final IndividualResource james = usersFixture.james();
IndividualResource jessica = usersFixture.jessica();
final IndividualResource nod = itemsFixture.basedUponNod(builder -> builder.withTemporaryLocation(homeLocation.getId()));
final IndividualResource otherServicePoint = servicePointsFixture.cd2();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
requestsFixture.placeItemLevelHoldShelfRequest(nod, jessica, ClockUtil.getZonedDateTime(), otherServicePoint.getId());
final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(otherServicePoint.getId()));
JsonObject itemRepresentation = checkInResponse.getItem();
assertThat("item should be present in response", itemRepresentation, notNullValue());
assertThat("ID should be included for item", itemRepresentation.getString("id"), is(nod.getId()));
assertThat("title is included for item", itemRepresentation.getString("title"), is("Nod"));
assertThat("barcode is included for item", itemRepresentation.getString("barcode"), is("565578437802"));
assertThat("item status is not awaiting pickup", itemRepresentation.getJsonObject("status").getString("name"), is("Awaiting pickup"));
assertThat("in transit item should not have a destination", itemRepresentation.containsKey("inTransitDestinationServicePointId"), is(false));
JsonObject loanRepresentation = checkInResponse.getLoan();
assertThat("closed loan should be present in response", loanRepresentation, notNullValue());
assertThat("in transit item (in loan) should not have a destination", loanRepresentation.getJsonObject("item").containsKey("inTransitDestinationServicePointId"), is(false));
JsonObject updatedNod = itemsClient.getById(nod.getId()).getJson();
assertThat("stored item status is not awaiting pickup", updatedNod.getJsonObject("status").getString("name"), is("Awaiting pickup"));
assertThat("in transit item in storage should not have a destination", updatedNod.containsKey("inTransitDestinationServicePointId"), is(false));
final JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
assertThat("stored loan status is not closed", storedLoan.getJsonObject("status").getString("name"), is("Closed"));
assertThat("item status snapshot in storage is not awaiting pickup", storedLoan.getString("itemStatus"), is("Awaiting pickup"));
assertThat("Checkin Service Point Id should be stored", storedLoan.getString("checkinServicePointId"), is(otherServicePoint.getId()));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method isAvailableWhenCheckedInToReturnItemAtOtherServingServicePointForHomeLocation.
@Test
void isAvailableWhenCheckedInToReturnItemAtOtherServingServicePointForHomeLocation() {
final IndividualResource primaryServicePoint = servicePointsFixture.cd1();
final IndividualResource otherServingServicePoint = servicePointsFixture.cd2();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.getId()).servedBy(otherServingServicePoint.getId()).withPrimaryServicePoint(primaryServicePoint.getId()));
final IndividualResource james = usersFixture.james();
final IndividualResource nod = itemsFixture.basedUponNod(builder -> builder.withTemporaryLocation(homeLocation.getId()));
final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(otherServingServicePoint.getId()));
JsonObject itemRepresentation = checkInResponse.getItem();
assertThat("item should be present in response", itemRepresentation, notNullValue());
assertThat("ID should be included for item", itemRepresentation.getString("id"), is(nod.getId()));
assertThat("title is included for item", itemRepresentation.getString("title"), is("Nod"));
assertThat("barcode is included for item", itemRepresentation.getString("barcode"), is("565578437802"));
assertThat("item status is not available", itemRepresentation.getJsonObject("status").getString("name"), is("Available"));
assertThat("available item should not have a destination", itemRepresentation.containsKey("inTransitDestinationServicePointId"), is(false));
JsonObject loanRepresentation = checkInResponse.getLoan();
assertThat("closed loan should be present in response", loanRepresentation, notNullValue());
assertThat("in transit item (in loan) should have a destination", loanRepresentation.getJsonObject("item").containsKey("inTransitDestinationServicePointId"), is(false));
JsonObject updatedNod = itemsClient.getById(nod.getId()).getJson();
assertThat("stored item status is not available", updatedNod.getJsonObject("status").getString("name"), is("Available"));
assertThat("available item in storage should not have a destination", updatedNod.containsKey("inTransitDestinationServicePointId"), is(false));
final JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
assertThat("stored loan status is not closed", storedLoan.getJsonObject("status").getString("name"), is("Closed"));
assertThat("item status snapshot in storage is not available", storedLoan.getString("itemStatus"), is("Available"));
assertThat("Checkin Service Point Id should be stored", storedLoan.getString("checkinServicePointId"), is(otherServingServicePoint.getId()));
}
Aggregations