use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method isAvailableWhenCheckedInToReceiveAtNonPrimaryServicePointForHomeLocation.
@Test
void isAvailableWhenCheckedInToReceiveAtNonPrimaryServicePointForHomeLocation() {
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 otherServicePoint = servicePointsFixture.cd3();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(otherServicePoint.getId()));
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 not be present in response", loanRepresentation, nullValue());
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 should not change", storedLoan.getString("itemStatus"), is("In transit"));
assertThat("Checkin Service Point Id should not change", storedLoan.getString("checkinServicePointId"), is(otherServicePoint.getId()));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method isAvailableWhenCheckedInToReceiveAtPrimaryServicePointForHomeLocation.
@Test
void isAvailableWhenCheckedInToReceiveAtPrimaryServicePointForHomeLocation() {
final IndividualResource primaryServicePoint = servicePointsFixture.cd1();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.getId()).withPrimaryServicePoint(primaryServicePoint.getId()));
final IndividualResource james = usersFixture.james();
final IndividualResource nod = itemsFixture.basedUponNod(builder -> builder.withTemporaryLocation(homeLocation.getId()));
final IndividualResource otherServicePoint = servicePointsFixture.cd2();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(otherServicePoint.getId()));
final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(primaryServicePoint.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 not be present in response", loanRepresentation, nullValue());
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 should not change", storedLoan.getString("itemStatus"), is("In transit"));
assertThat("Checkin Service Point Id should not change", storedLoan.getString("checkinServicePointId"), is(otherServicePoint.getId()));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method isPlacedInTransitWhenCheckedInToReturnItemAtServicePointNotServingHomeLocation.
@Test
void isPlacedInTransitWhenCheckedInToReturnItemAtServicePointNotServingHomeLocation() {
final IndividualResource primaryServicePoint = servicePointsFixture.cd1();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.getId()).withPrimaryServicePoint(primaryServicePoint.getId()));
final IndividualResource james = usersFixture.james();
final ItemResource nod = itemsFixture.basedUponNod(builder -> builder.withTemporaryLocation(homeLocation.getId()));
final IndividualResource otherServicePoint = servicePointsFixture.cd2();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
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 in transit", itemRepresentation.getJsonObject("status").getString("name"), is("In transit"));
assertThat("in transit item should have a destination", itemRepresentation.getString("inTransitDestinationServicePointId"), is(primaryServicePoint.getId()));
assertThat("in transit item should have a extended destination properties", itemRepresentation.containsKey("inTransitDestinationServicePoint"), is(true));
final JsonObject destinationServicePoint = itemRepresentation.getJsonObject("inTransitDestinationServicePoint");
assertThat("extended destination properties should include id", destinationServicePoint.getString("id"), is(primaryServicePoint.getId()));
assertThat("extended destination properties should include name", destinationServicePoint.getString("name"), is("Circ Desk 1"));
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").getString("inTransitDestinationServicePointId"), is(primaryServicePoint.getId()));
JsonObject updatedNod = itemsClient.getById(nod.getId()).getJson();
assertThat("stored item status is not in transit", updatedNod.getJsonObject("status").getString("name"), is("In transit"));
assertThat("in transit item in storage should have a destination", updatedNod.getString("inTransitDestinationServicePointId"), is(primaryServicePoint.getId()));
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 in transit", storedLoan.getString("itemStatus"), is("In transit"));
assertThat("Checkin Service Point Id should be stored", storedLoan.getString("checkinServicePointId"), is(otherServicePoint.getId()));
Map<String, Matcher<String>> staffSlipContextMatchers = new HashMap<>();
staffSlipContextMatchers.putAll(getItemContextMatchers(nod, true));
staffSlipContextMatchers.putAll(getTransitContextMatchers(otherServicePoint, primaryServicePoint));
JsonObject staffSlipContext = checkInResponse.getStaffSlipContext();
assertThat(staffSlipContext, JsonObjectMatcher.allOfPaths(staffSlipContextMatchers));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method isAvailableWhenCheckedInToReturnItemAtPrimaryServicePointForHomeLocation.
@Test
void isAvailableWhenCheckedInToReturnItemAtPrimaryServicePointForHomeLocation() {
final IndividualResource primaryServicePoint = servicePointsFixture.cd1();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.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(primaryServicePoint.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(primaryServicePoint.getId()));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method itemCheckedInEventIsPublished.
@Test
void itemCheckedInEventIsPublished() {
final IndividualResource james = usersFixture.james();
final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withPermanentLocation(homeLocation.getId()));
ZonedDateTime checkOutDate = ZonedDateTime.of(2020, 1, 18, 18, 0, 0, 0, UTC);
ZonedDateTime checkInDate = ZonedDateTime.of(2020, 1, 22, 15, 30, 0, 0, UTC);
checkOutFixture.checkOutByBarcode(nod, james, checkOutDate);
CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate).at(checkInServicePointId));
JsonObject checkedInLoan = checkInResponse.getLoan();
// There should be four events published - first ones for "check out" and check out log event, second ones for "check in" and check in log event
final var publishedEvents = waitAtMost(2, SECONDS).until(FakePubSub::getPublishedEvents, hasSize(4));
final var checkedInEvent = publishedEvents.findFirst(byEventType(ITEM_CHECKED_IN.name()));
assertThat(checkedInEvent, isValidItemCheckedInEvent(checkedInLoan));
final var checkInLogEvent = publishedEvents.findFirst(byLogEventType(CHECK_IN.value()));
assertThat(checkInLogEvent, isValidCheckInLogEvent(checkedInLoan));
assertThatPublishedLoanLogRecordEventsAreValid(checkedInLoan);
}
Aggregations