use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueFineShouldBeChargedWhenItemIsOverdue.
@Test
void overdueFineShouldBeChargedWhenItemIsOverdue() {
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()));
checkOutFixture.checkOutByBarcode(nod, james, ZonedDateTime.of(2020, 1, 1, 12, 0, 0, 0, UTC));
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(ZonedDateTime.of(2020, 1, 25, 12, 0, 0, 0, UTC)).at(checkInServicePointId));
JsonObject checkedInLoan = checkInResponse.getLoan();
waitAtMost(1, SECONDS).until(accountsClient::getAll, hasSize(1));
List<JsonObject> createdAccounts = accountsClient.getAll();
assertThat("Fee/fine record should be created", createdAccounts, hasSize(1));
JsonObject account = createdAccounts.get(0);
assertThat(account, isValidOverdueFine(checkedInLoan, nod, homeLocation.getJson().getString("name"), ownerId, feeFineId, 5.0));
waitAtMost(1, SECONDS).until(feeFineActionsClient::getAll, hasSize(1));
List<JsonObject> createdFeeFineActions = feeFineActionsClient.getAll();
assertThat("Fee/fine action record should be created", createdFeeFineActions, hasSize(1));
JsonObject createdFeeFineAction = createdFeeFineActions.get(0);
assertThat("user ID is included", createdFeeFineAction.getString("userId"), is(checkedInLoan.getString("userId")));
assertThat("account ID is included", createdFeeFineAction.getString("accountId"), is(account.getString("id")));
assertThat("balance is included", createdFeeFineAction.getDouble("balance"), is(account.getDouble("amount")));
assertThat("amountAction is included", createdFeeFineAction.getDouble("amountAction"), is(account.getDouble("amount")));
assertThat("typeAction is included", createdFeeFineAction.getString("typeAction"), is("Overdue fine"));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueFineIsChargedForCorrectOwnerWhenMultipleOwnersExist.
@Test
void overdueFineIsChargedForCorrectOwnerWhenMultipleOwnersExist() {
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()));
checkOutFixture.checkOutByBarcode(nod, james, ZonedDateTime.of(2020, 1, 1, 12, 0, 0, 0, UTC));
for (int i = 0; i < 10; i++) {
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(UUID.randomUUID()).withOwner("fee-fine-owner-" + i));
}
waitAtMost(3, SECONDS).until(feeFineOwnersClient::getAll, hasSize(10));
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", homeLocation.getJson().getString("primaryServicePoint"));
servicePointOwner.put("label", "label");
UUID servicePointOwnerId = UUID.randomUUID();
feeFineOwnersClient.create(new FeeFineOwnerBuilder().withId(servicePointOwnerId).withOwner("fee-fine-owner").withServicePointOwner(Collections.singletonList(servicePointOwner)));
UUID feeFineId = UUID.randomUUID();
feeFinesClient.create(new FeeFineBuilder().withId(feeFineId).withFeeFineType("Overdue fine").withAutomatic(true));
CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(ZonedDateTime.of(2020, 1, 25, 12, 0, 0, 0, UTC)).at(checkInServicePointId));
JsonObject checkedInLoan = checkInResponse.getLoan();
waitAtMost(3, SECONDS).until(accountsClient::getAll, hasSize(1));
List<JsonObject> createdAccounts = accountsClient.getAll();
assertThat("Fee/fine record should be created", createdAccounts, hasSize(1));
JsonObject account = createdAccounts.get(0);
assertThat(account, isValidOverdueFine(checkedInLoan, nod, homeLocation.getJson().getString("name"), servicePointOwnerId, feeFineId, 5.0));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InHouseUseCheckInTest method isInHouseUseWhenCheckInServicePointIsPrimaryForHomeLocation.
@Test
void isInHouseUseWhenCheckInServicePointIsPrimaryForHomeLocation() {
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()));
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);
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class ServicePointCheckOutTests method isInTransitWhenCheckedOutAtNonPickupServicePoint.
@Test
void isInTransitWhenCheckedOutAtNonPickupServicePoint() {
final IndividualResource checkInServicePoint = servicePointsFixture.cd1();
final IndividualResource checkOutServicePoint = servicePointsFixture.cd2();
final IndividualResource primaryServicePoint = servicePointsFixture.cd4();
final IndividualResource requestServicePoint = primaryServicePoint;
final IndividualResource james = usersFixture.james();
final IndividualResource jessica = usersFixture.jessica();
final IndividualResource homeLocation = locationsFixture.basedUponExampleLocation(builder -> builder.servedBy(primaryServicePoint.getId()).withPrimaryServicePoint(primaryServicePoint.getId()));
final IndividualResource nod = itemsFixture.basedUponNod(builder -> builder.withPermanentLocation(homeLocation.getId()));
checkOutFixture.checkOutByBarcode(nod, james);
final IndividualResource request = requestsFixture.placeItemLevelHoldShelfRequest(nod, jessica, ClockUtil.getZonedDateTime(), requestServicePoint.getId());
final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(checkInServicePoint.getId()));
JsonObject itemRepresentation = checkInResponse.getItem();
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 4"));
final IndividualResource checkOutResponse = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(nod).to(jessica).at(checkOutServicePoint.getId()));
itemRepresentation = checkOutResponse.getJson().getJsonObject("item");
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 checked out", itemRepresentation.getJsonObject("status").getString("name"), is("Checked out"));
JsonObject loanRepresentation = checkOutResponse.getJson();
assertThat("closed loan should be present in response", loanRepresentation, notNullValue());
JsonObject updatedNod = itemsClient.getById(nod.getId()).getJson();
assertThat("stored item status is checked out", updatedNod.getJsonObject("status").getString("name"), is("Checked out"));
final JsonObject storedLoan = loansStorageClient.getById(checkOutResponse.getId()).getJson();
assertThat("stored loan status is open", storedLoan.getJsonObject("status").getString("name"), is("Open"));
assertThat("item status snapshot in storage is checked out", storedLoan.getString("itemStatus"), is("Checked out"));
final Response getByIdResponse = requestsClient.getById(request.getId());
MatcherAssert.assertThat(getByIdResponse, hasStatus(HTTP_OK));
final JsonObject storedRequest = getByIdResponse.getJson();
assertThat("request status snapshot in storage is closed - filled", storedRequest.getString("status"), is("Closed - Filled"));
}
use of api.support.CheckInByBarcodeResponse in project mod-circulation by folio-org.
the class InTransitToHomeLocationTests method remainsInTransitWhenCheckedInToReceiveAtServicePointNotForHomeLocation.
@Test
void remainsInTransitWhenCheckedInToReceiveAtServicePointNotForHomeLocation() {
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 firstOtherServicePoint = servicePointsFixture.cd2();
final IndividualResource loan = checkOutFixture.checkOutByBarcode(nod, james);
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(firstOtherServicePoint.getId()));
final IndividualResource secondOtherServicePoint = servicePointsFixture.cd3();
final CheckInByBarcodeResponse checkInResponse = checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).at(secondOtherServicePoint.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 not be present in response", loanRepresentation, nullValue());
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(firstOtherServicePoint.getId()));
}
Aggregations