Search in sources :

Example 16 with CheckInByBarcodeResponse

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

the class CheckInByBarcodeTests method shouldNotSendPatronNoticeWhenCheckInNoticeIsDefinedAndCheckInDoesNotCloseLoan.

@Test
void shouldNotSendPatronNoticeWhenCheckInNoticeIsDefinedAndCheckInDoesNotCloseLoan() {
    UUID checkInTemplateId = UUID.randomUUID();
    JsonObject checkOutNoticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(checkInTemplateId).withCheckInEvent().create();
    JsonObject renewNoticeConfiguration = new NoticeConfigurationBuilder().withTemplateId(UUID.randomUUID()).withEventType("Renew").create();
    NoticePolicyBuilder noticePolicy = new NoticePolicyBuilder().withName("Policy with checkout notice").withLoanNotices(Arrays.asList(checkOutNoticeConfiguration, renewNoticeConfiguration));
    use(noticePolicy);
    final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
    final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.withPrimaryServicePoint(checkInServicePointId));
    final IndividualResource nod = itemsFixture.basedUponNod(builder -> builder.withTemporaryLocation(homeLocation.getId()));
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(nod, ZonedDateTime.of(2018, 3, 5, 14, 23, 41, 0, UTC), checkInServicePointId);
    assertThat("Response should not include a loan", checkInResponse.getJson().containsKey("loan"), is(false));
    verifyNumberOfSentNotices(0);
    verifyNumberOfPublishedEvents(NOTICE, 0);
    verifyNumberOfPublishedEvents(NOTICE_ERROR, 0);
}
Also used : NoticePolicyBuilder(api.support.builders.NoticePolicyBuilder) NoticeConfigurationBuilder(api.support.builders.NoticeConfigurationBuilder) JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 17 with CheckInByBarcodeResponse

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

the class CheckInByBarcodeTests method canCheckinItemWhenRequestForAnotherItemOfSameInstanceExists.

@Test
void canCheckinItemWhenRequestForAnotherItemOfSameInstanceExists() {
    configurationsFixture.enableTlrFeature();
    List<ItemResource> items = itemsFixture.createMultipleItemsForTheSameInstance(2);
    ItemResource firstItem = items.get(0);
    ItemResource secondItem = items.get(1);
    UUID instanceId = firstItem.getInstanceId();
    IndividualResource firstRequest = requestsFixture.placeItemLevelPageRequest(firstItem, instanceId, usersFixture.jessica());
    assertThat(firstRequest.getJson(), allOf(isOpenNotYetFilled(), hasPosition(1)));
    CheckInByBarcodeResponse response = checkInFixture.checkInByBarcode(secondItem);
    assertEquals(200, response.getResponse().getStatusCode());
    assertThat(requestsFixture.getById(firstRequest.getId()).getJson(), allOf(isOpenNotYetFilled(), hasPosition(1)));
}
Also used : UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) ItemResource(api.support.http.ItemResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 18 with CheckInByBarcodeResponse

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

the class CheckInByBarcodeTests method overdueRecallFineShouldBeChargedWhenItemIsOverdueAfterRecall.

@Test
void overdueRecallFineShouldBeChargedWhenItemIsOverdueAfterRecall() {
    useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.facultyStandardDoNotCountClosed().getId(), lostItemFeePoliciesFixture.facultyStandard().getId());
    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, 15, 0, 0, 0, 0, UTC);
    ZonedDateTime recallRequestExpirationDate = checkOutDate.plusDays(5);
    ZonedDateTime checkInDate = checkOutDate.plusDays(10);
    mockClockManagerToReturnFixedDateTime(ZonedDateTime.of(2020, 1, 18, 0, 0, 0, 0, UTC));
    checkOutFixture.checkOutByBarcode(nod, james, checkOutDate);
    Address address = SiriusBlack();
    IndividualResource requester = usersFixture.steve(builder -> builder.withAddress(address));
    requestsFixture.place(new RequestBuilder().withId(UUID.randomUUID()).open().recall().forItem(nod).by(requester).fulfilToHoldShelf().withRequestExpiration(toLocalDate(recallRequestExpirationDate)).withHoldShelfExpiration(toLocalDate(recallRequestExpirationDate)).withPickupServicePointId(UUID.fromString(homeLocation.getJson().getString("primaryServicePoint"))).withTags(new RequestBuilder.Tags(asList("new", "important"))));
    JsonObject servicePointOwner = new JsonObject();
    servicePointOwner.put("value", homeLocation.getJson().getString("primaryServicePoint"));
    servicePointOwner.put("label", "label");
    UUID ownerId = UUID.randomUUID();
    feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(ownerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
    UUID feeFineId = UUID.randomUUID();
    feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withOwnerId(ownerId).withAutomatic(true));
    CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(checkInDate).at(checkInServicePointId));
    JsonObject checkedInLoan = checkInResponse.getLoan();
    final var createdAccounts = waitAtMost(1, SECONDS).until(accountsClient::getAll, hasSize(1));
    mockClockManagerToReturnDefaultDateTime();
    JsonObject account = createdAccounts.get(0);
    assertThat(account, isValidOverdueFine(checkedInLoan, nod, homeLocation.getJson().getString("name"), ownerId, feeFineId, 10.0));
}
Also used : Address(api.support.builders.Address) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) JsonObject(io.vertx.core.json.JsonObject) FeeFineBuilder(api.support.builders.FeeFineBuilder) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) FeeFineOwnerBuilder(api.support.builders.FeeFineOwnerBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 19 with CheckInByBarcodeResponse

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

the class CheckInByBarcodeTests method canCheckInAnItemWithoutAnOpenLoan.

@Test
void canCheckInAnItemWithoutAnOpenLoan() {
    final UUID checkInServicePointId = servicePointsFixture.cd1().getId();
    final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(item -> item.withPrimaryServicePoint(checkInServicePointId));
    final IndividualResource nod = itemsFixture.basedUponNod(item -> item.withTemporaryLocation(homeLocation.getId()).withEnumeration("v.70:no.1-6").withChronology("1987:Jan.-June").withVolume("testVolume"));
    final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(nod, ZonedDateTime.of(2018, 3, 5, 14, 23, 41, 0, UTC), checkInServicePointId);
    assertThat("Response should not include a loan", checkInResponse.getJson().containsKey("loan"), is(false));
    assertThat("Response should include an item", checkInResponse.getJson().containsKey("item"), is(true));
    final JsonObject itemFromResponse = checkInResponse.getItem();
    assertThat("ID should be included for item", itemFromResponse.getString("id"), is(nod.getId()));
    assertThat("title is included for item", itemFromResponse.getString("title"), is("Nod"));
    assertThat("has item enumeration", itemFromResponse.getString("enumeration"), is("v.70:no.1-6"));
    assertThat("has item chronology", itemFromResponse.getString("chronology"), is("1987:Jan.-June"));
    assertThat("has item volume", itemFromResponse.getString("volume"), is("testVolume"));
    assertThat("barcode is included for item", itemFromResponse.getString("barcode"), is("565578437802"));
}
Also used : JsonObject(io.vertx.core.json.JsonObject) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) CheckInByBarcodeResponse(api.support.CheckInByBarcodeResponse) Test(org.junit.jupiter.api.Test)

Example 20 with CheckInByBarcodeResponse

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

the class CheckInByBarcodeTests method canCreateStaffSlipContextOnCheckInByBarcode.

@Test
void canCreateStaffSlipContextOnCheckInByBarcode() {
    ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
    ZonedDateTime requestDate = ZonedDateTime.of(2019, 7, 22, 10, 22, 54, 0, UTC);
    IndividualResource servicePoint = servicePointsFixture.cd1();
    Address address = SiriusBlack();
    IndividualResource requester = usersFixture.steve(builder -> builder.withAddress(address));
    final var requestExpiration = java.time.LocalDate.of(2019, 7, 30);
    final var holdShelfExpiration = java.time.LocalDate.of(2019, 8, 31);
    IndividualResource request = requestsFixture.place(new RequestBuilder().withId(UUID.randomUUID()).open().page().forItem(item).by(requester).withRequestDate(requestDate).fulfilToHoldShelf().withRequestExpiration(requestExpiration).withHoldShelfExpiration(holdShelfExpiration).withPickupServicePointId(servicePoint.getId()).withDeliveryAddressType(addressTypesFixture.home().getId()).withPatronComments("I need the book").withTags(new RequestBuilder.Tags(asList("new", "important"))));
    ZonedDateTime checkInDate = ZonedDateTime.of(2019, 7, 25, 14, 23, 41, 0, UTC);
    CheckInByBarcodeResponse response = checkInFixture.checkInByBarcode(item, checkInDate, servicePoint.getId());
    User requesterUser = new User(requester.getJson());
    JsonObject staffSlipContext = response.getStaffSlipContext();
    JsonObject userContext = staffSlipContext.getJsonObject("requester");
    JsonObject requestContext = staffSlipContext.getJsonObject("request");
    assertThat(userContext.getString("firstName"), is(requesterUser.getFirstName()));
    assertThat(userContext.getString("lastName"), is(requesterUser.getLastName()));
    assertThat(userContext.getString("middleName"), is(requesterUser.getMiddleName()));
    assertThat(userContext.getString("barcode"), is(requesterUser.getBarcode()));
    assertThat(userContext.getString("addressLine1"), is(address.getAddressLineOne()));
    assertThat(userContext.getString("addressLine2"), is(address.getAddressLineTwo()));
    assertThat(userContext.getString("city"), is(address.getCity()));
    assertThat(userContext.getString("region"), is(address.getRegion()));
    assertThat(userContext.getString("postalCode"), is(address.getPostalCode()));
    assertThat(userContext.getString("countryId"), is(address.getCountryId()));
    assertThat(requestContext.getString("deliveryAddressType"), is(addressTypesFixture.home().getJson().getString("addressType")));
    assertThat(requestContext.getString("requestExpirationDate"), isEquivalentTo(ZonedDateTime.of(requestExpiration.atTime(23, 59, 59), ZoneOffset.UTC)));
    assertThat(requestContext.getString("holdShelfExpirationDate"), isEquivalentTo(ZonedDateTime.of(holdShelfExpiration.atStartOfDay(), ZoneOffset.UTC)));
    assertThat(requestContext.getString("requestID"), is(request.getId()));
    assertThat(requestContext.getString("servicePointPickup"), is(servicePoint.getJson().getString("name")));
    assertThat(requestContext.getString("patronComments"), is("I need the book"));
}
Also used : User(org.folio.circulation.domain.User) Address(api.support.builders.Address) CheckInByBarcodeRequestBuilder(api.support.builders.CheckInByBarcodeRequestBuilder) RequestBuilder(api.support.builders.RequestBuilder) ZonedDateTime(java.time.ZonedDateTime) ClockUtil.getZonedDateTime(org.folio.circulation.support.utils.ClockUtil.getZonedDateTime) JsonObject(io.vertx.core.json.JsonObject) 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