use of api.support.builders.FeeFineOwnerBuilder in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method overdueFineIsNotCreatedWhenThereIsNoOwnerForServicePoint.
@Test
void overdueFineIsNotCreatedWhenThereIsNoOwnerForServicePoint() {
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));
final UUID servicePointForOwner = servicePointsFixture.cd2().getId();
JsonObject servicePointOwner = new JsonObject();
servicePointOwner.put("value", servicePointForOwner.toString());
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));
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(ZonedDateTime.of(2020, 1, 25, 12, 0, 0, 0, UTC)).at(checkInServicePointId));
waitAtMost(1, SECONDS);
List<JsonObject> createdAccounts = accountsClient.getAll();
assertThat("No fee/fine records should have been created", createdAccounts, hasSize(0));
}
use of api.support.builders.FeeFineOwnerBuilder 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.builders.FeeFineOwnerBuilder in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method noOverdueFineShouldBeChargedForOverdueFinePolicyWithNoOverdueFine.
@Test
void noOverdueFineShouldBeChargedForOverdueFinePolicyWithNoOverdueFine() {
useFallbackPolicies(loanPoliciesFixture.canCirculateRolling().getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.noOverdueFine().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));
checkInFixture.checkInByBarcode(new CheckInByBarcodeRequestBuilder().forItem(nod).on(ZonedDateTime.of(2020, 1, 25, 12, 0, 0, 0, UTC)).at(checkInServicePointId));
waitAtLeast(1, SECONDS).until(accountsClient::getAll, empty());
waitAtLeast(1, SECONDS).until(feeFineActionsClient::getAll, empty());
}
use of api.support.builders.FeeFineOwnerBuilder 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.builders.FeeFineOwnerBuilder in project mod-circulation by folio-org.
the class RenewalAPITests method overdueFineShouldNotBeChargedWhenShouldBeForgiven.
@Test
void overdueFineShouldNotBeChargedWhenShouldBeForgiven() throws InterruptedException {
IndividualResource loanPolicy = loanPoliciesFixture.create(new LoanPolicyBuilder().rolling(Period.from(10, "Days")));
useFallbackPolicies(loanPolicy.getId(), requestPoliciesFixture.allowAllRequestPolicy().getId(), noticePoliciesFixture.activeNotice().getId(), overdueFinePoliciesFixture.facultyStandardShouldForgiveFine().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));
loansFixture.renewLoan(nod, james);
TimeUnit.SECONDS.sleep(1);
List<JsonObject> createdAccounts = accountsClient.getAll();
assertThat("Fee/fine record shouldn't have been created", createdAccounts, hasSize(0));
}
Aggregations