Search in sources :

Example 26 with CheckInByBarcodeResponse

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()));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 27 with CheckInByBarcodeResponse

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()));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Aggregations

CheckInByBarcodeResponse (api.support.CheckInByBarcodeResponse)27 IndividualResource (api.support.http.IndividualResource)27 Test (org.junit.jupiter.api.Test)27 JsonObject (io.vertx.core.json.JsonObject)22 CheckInByBarcodeRequestBuilder (api.support.builders.CheckInByBarcodeRequestBuilder)19 UUID (java.util.UUID)16 ZonedDateTime (java.time.ZonedDateTime)9 ClockUtil.getZonedDateTime (org.folio.circulation.support.utils.ClockUtil.getZonedDateTime)7 ItemResource (api.support.http.ItemResource)6 RequestBuilder (api.support.builders.RequestBuilder)5 FeeFineBuilder (api.support.builders.FeeFineBuilder)4 FeeFineOwnerBuilder (api.support.builders.FeeFineOwnerBuilder)4 JsonObjectMatcher (api.support.matchers.JsonObjectMatcher)3 HashMap (java.util.HashMap)3 Response (org.folio.circulation.support.http.client.Response)3 Matcher (org.hamcrest.Matcher)3 Address (api.support.builders.Address)2 NoticeConfigurationBuilder (api.support.builders.NoticeConfigurationBuilder)2 NoticePolicyBuilder (api.support.builders.NoticePolicyBuilder)2 TemplateContextMatchers.servicePointNameMatcher (api.support.fixtures.TemplateContextMatchers.servicePointNameMatcher)2