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);
}
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)));
}
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));
}
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"));
}
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"));
}
Aggregations