Search in sources :

Example 1 with CheckInByBarcodeResponse

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

the class InHouseUseCheckInTest method isNotInHouseUseWhenItemIsRequested.

@Test
void isNotInHouseUseWhenItemIsRequested() {
    final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
    final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(checkInServicePointId));
    final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withTemporaryLocation(homeLocation.getId()));
    requestsFixture.place(new RequestBuilder().page().forItem(nod).withPickupServicePointId(checkInServicePointId).by(usersFixture.james()));
    assertThat(requestsFixture.getQueueFor(nod).getTotalRecords(), is(1));
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(nod, checkInServicePointId);
    assertThat(checkInResponse.getJson().containsKey("loan"), is(false));
    assertThat(checkInResponse.getJson().containsKey("item"), is(true));
    assertThat(checkInResponse.getInHouseUse(), is(false));
}
Also used : RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 2 with CheckInByBarcodeResponse

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

the class InHouseUseCheckInTest method isInHouseUseWhenItemHasClosedRequests.

@Test
void isInHouseUseWhenItemHasClosedRequests() {
    final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
    final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(checkInServicePointId));
    final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withTemporaryLocation(homeLocation.getId()));
    requestsFixture.place(new RequestBuilder().page().forItem(nod).withPickupServicePointId(checkInServicePointId).by(usersFixture.james()));
    IndividualResource recallRequest = requestsFixture.place(new RequestBuilder().recall().forItem(nod).withPickupServicePointId(checkInServicePointId).by(usersFixture.charlotte()));
    requestsFixture.cancelRequest(recallRequest);
    // Fulfill the page request
    checkOutFixture.checkOutByBarcode(nod, usersFixture.james());
    checkInFixture.checkInByBarcode(nod, checkInServicePointId);
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(nod, checkInServicePointId);
    assertThat(checkInResponse.getJson().containsKey("loan"), is(false));
    assertThat(checkInResponse.getJson().containsKey("item"), is(true));
    assertThat(checkInResponse.getInHouseUse(), is(true));
    verifyLastCheckInWasRecorded(nod.getId(), checkInServicePointId);
    MultipleJsonRecords requestsForItem = requestsFixture.getRequests(queryFromTemplate("itemId=%s", nod.getId()), noLimit(), noOffset());
    assertThat(requestsForItem.totalRecords(), is(2));
}
Also used : MultipleJsonRecords(api.support.MultipleJsonRecords) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 3 with CheckInByBarcodeResponse

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

the class InHouseUseCheckInTest method isNotInHouseUseWhenCheckInServicePointIsNotServingHomeLocation.

@Test
void isNotInHouseUseWhenCheckInServicePointIsNotServingHomeLocation() {
    final UUID itemServicePointId = servicePointsFixture.cd1().getId();
    final UUID checkInServicePointId = servicePointsFixture.cd2().getId();
    final IndividualResource itemLocation = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(itemServicePointId));
    final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withTemporaryLocation(itemLocation.getId()));
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(nod, checkInServicePointId);
    assertThat(checkInResponse.getJson().containsKey("loan"), is(false));
    assertThat(checkInResponse.getJson().containsKey("item"), is(true));
    assertThat(checkInResponse.getInHouseUse(), is(false));
}
Also used : UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 4 with CheckInByBarcodeResponse

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

the class ServicePointCheckInTests method isPlacedInTransitWhenCheckedInAtAlternatePickupServicePoint.

@Test
void isPlacedInTransitWhenCheckedInAtAlternatePickupServicePoint() {
    final IndividualResource checkInServicePoint = servicePointsFixture.cd1();
    final IndividualResource requestServicePoint = servicePointsFixture.cd2();
    final IndividualResource primaryServicePoint = servicePointsFixture.cd3();
    final IndividualResource james = usersFixture.james();
    final IndividualResource jessica = usersFixture.jessica();
    final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.getId()).withPrimaryServicePoint(primaryServicePoint.getId()));
    final ItemResource nod = itemsFixture.basedUponNod(builder -> builder.withPermanentLocation(homeLocation.getId()));
    final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
    final IndividualResource request = requestsFixture.placeItemLevelHoldShelfRequest(nod, jessica, ClockUtil.getZonedDateTime(), requestServicePoint.getId());
    final ZonedDateTime beforeCheckIn = ClockUtil.getZonedDateTime();
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(checkInServicePoint.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 in transit", itemRepresentation.getJsonObject("status").getString("name"), is("In transit"));
    assertThat("in transit item should have a destination", itemRepresentation.getString("inTransitDestinationServicePointId"), is(requestServicePoint.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(requestServicePoint.getId()));
    assertThat("extended destination properties should include name", destinationServicePoint.getString("name"), is("Circ Desk 2"));
    JsonObject loanRepresentation = checkInResponse.getLoan();
    assertThat("closed loan should be present in response", loanRepresentation, notNullValue());
    JsonObject updatedNod = itemsClient.getById(nod.getId()).getJson();
    assertThat("stored item status is in transit", updatedNod.getJsonObject("status").getString("name"), is("In transit"));
    assertThat("in transit item in storage should have a destination", updatedNod.getString("inTransitDestinationServicePointId"), is(requestServicePoint.getId()));
    final JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
    assertThat("stored loan status is closed", storedLoan.getJsonObject("status").getString("name"), is("Closed"));
    assertThat("item status snapshot in storage is in transit", storedLoan.getString("itemStatus"), is("In transit"));
    assertThat("Checkin Service Point Id should be stored", storedLoan.getString("checkinServicePointId"), is(checkInServicePoint.getId()));
    final Response getByIdResponse = requestsClient.getById(request.getId());
    assertThat(getByIdResponse, hasStatus(HTTP_OK));
    assertThat("request status snapshot in storage is open - in transit", getByIdResponse.getJson().getString("status"), is("Open - In transit"));
    Map<String, Matcher<String>> staffSlipContextMatchers = new HashMap<>();
    staffSlipContextMatchers.putAll(getItemContextMatchers(nod, true));
    staffSlipContextMatchers.putAll(getTransitContextMatchers(checkInServicePoint, requestServicePoint));
    staffSlipContextMatchers.putAll(getRequesterContextMatchers(jessica));
    staffSlipContextMatchers.put("request.servicePointPickup", servicePointNameMatcher(requestServicePoint));
    staffSlipContextMatchers.put("request.requestID", is(request.getId()));
    staffSlipContextMatchers.put("item.lastCheckedInDateTime", TextDateTimeMatcher.withinSecondsAfter(2, beforeCheckIn));
    JsonObject staffSlipContext = checkInResponse.getStaffSlipContext();
    assertThat(staffSlipContext, JsonObjectMatcher.allOfPaths(staffSlipContextMatchers));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) ZonedDateTime(java.time.ZonedDateTime) JsonObjectMatcher(api.support.matchers.JsonObjectMatcher) TemplateContextMatchers.servicePointNameMatcher(api.support.fixtures.TemplateContextMatchers.servicePointNameMatcher) TextDateTimeMatcher(api.support.matchers.TextDateTimeMatcher) Matcher(org.hamcrest.Matcher) HashMap(java.util.HashMap) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 5 with CheckInByBarcodeResponse

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

the class ServicePointCheckInTests method isPlacedAwaitingPickupWhenCheckedInAtPickupServicePoint.

@Test
void isPlacedAwaitingPickupWhenCheckedInAtPickupServicePoint() {
    final IndividualResource checkInServicePoint = servicePointsFixture.cd1();
    final IndividualResource james = usersFixture.james();
    final IndividualResource jessica = usersFixture.jessica();
    final ItemResource nod = itemsFixture.basedUponNod();
    final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
    final IndividualResource request = requestsFixture.place(new RequestBuilder().hold().forItem(nod).by(jessica).withPickupServicePoint(checkInServicePoint).withRequestDate(ZonedDateTime.of(2019, 7, 5, 10, 0, 0, 0, UTC)).withRequestExpiration(LocalDate.of(2019, 7, 11)));
    final ZonedDateTime beforeCheckIn = ClockUtil.getZonedDateTime();
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(checkInServicePoint.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 awaiting pickup", itemRepresentation.getJsonObject("status").getString("name"), is("Awaiting pickup"));
    JsonObject loanRepresentation = checkInResponse.getLoan();
    assertThat("closed loan should be present in response", loanRepresentation, notNullValue());
    JsonObject updatedNod = itemsClient.getById(nod.getId()).getJson();
    assertThat("stored item status is awaiting pickup", updatedNod.getJsonObject("status").getString("name"), is("Awaiting pickup"));
    final JsonObject storedLoan = loansStorageClient.getById(loan.getId()).getJson();
    assertThat("stored loan status is closed", storedLoan.getJsonObject("status").getString("name"), is("Closed"));
    assertThat("item status snapshot in storage is awaiting pickup", storedLoan.getString("itemStatus"), is("Awaiting pickup"));
    assertThat("Checkin Service Point Id should be stored", storedLoan.getString("checkinServicePointId"), is(checkInServicePoint.getId()));
    final Response getByIdResponse = requestsClient.getById(request.getId());
    assertThat(getByIdResponse, hasStatus(HTTP_OK));
    final JsonObject storedRequest = getByIdResponse.getJson();
    assertThat("request status snapshot in storage is open - awaiting pickup", storedRequest.getString("status"), is("Open - Awaiting pickup"));
    IndividualResource requestAfterCheckIn = requestsClient.get(request.getId());
    Map<String, Matcher<String>> staffSlipContextMatchers = new HashMap<>();
    staffSlipContextMatchers.putAll(getItemContextMatchers(nod, true));
    staffSlipContextMatchers.putAll(getRequesterContextMatchers(jessica));
    staffSlipContextMatchers.putAll(getRequestContextMatchers(requestAfterCheckIn));
    staffSlipContextMatchers.put("request.requestID", is(request.getId()));
    staffSlipContextMatchers.put("item.lastCheckedInDateTime", TextDateTimeMatcher.withinSecondsAfter(2, beforeCheckIn));
    JsonObject staffSlipContext = checkInResponse.getStaffSlipContext();
    assertThat(staffSlipContext, JsonObjectMatcher.allOfPaths(staffSlipContextMatchers));
}
Also used : Response(org.folio.circulation.support.http.client.Response) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) RequestBuilder(api.support.builders.RequestBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) ZonedDateTime(java.time.ZonedDateTime) JsonObjectMatcher(api.support.matchers.JsonObjectMatcher) TemplateContextMatchers.servicePointNameMatcher(api.support.fixtures.TemplateContextMatchers.servicePointNameMatcher) TextDateTimeMatcher(api.support.matchers.TextDateTimeMatcher) Matcher(org.hamcrest.Matcher) HashMap(java.util.HashMap) JsonObject(io.vertx.core.json.JsonObject) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) 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