Search in sources :

Example 1 with LoanHistoryConfigurationBuilder

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

the class AnonymizeLoansAfterXIntervalTests method testOpenLoansWithFeesAndFinesNotAnonymizedAfterIntervalNotPassed.

/**
 * Scenario 2
 *
 *     Given:
 *         An Anonymize closed loans setting of "X interval after loan closes"
 *         An Anonymize closed loans with associated fees/fines setting of
 *         "Immediately"
 *         An open loan with an associated fee/fine
 *     When X interval has elapsed after the loan closed
 *     Then do not anonymize the loan
 */
@Test
void testOpenLoansWithFeesAndFinesNotAnonymizedAfterIntervalNotPassed() {
    LoanHistoryConfigurationBuilder loanHistoryConfig = new LoanHistoryConfigurationBuilder().loanCloseAnonymizeAfterXInterval(1, "minute").feeFineCloseAnonymizeImmediately();
    createConfiguration(loanHistoryConfig);
    IndividualResource loanResource = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item1).to(user).at(servicePoint.getId()));
    UUID loanID = loanResource.getId();
    createClosedAccountWithFeeFines(loanResource, getZonedDateTime().minusMinutes(1));
    assertThat(loanResource.getJson(), isOpen());
    mockClockManagerToReturnFixedDateTime(getZonedDateTime().plus(ONE_MINUTE_AND_ONE_MILLIS, ChronoUnit.MILLIS));
    anonymizeLoansInTenant();
    assertThat(loansStorageClient.getById(loanID).getJson(), not(isAnonymized()));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) LoanHistoryConfigurationBuilder(api.support.builders.LoanHistoryConfigurationBuilder) Test(org.junit.jupiter.api.Test)

Example 2 with LoanHistoryConfigurationBuilder

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

the class AnonymizeLoansAfterXIntervalTests method testClosedLoansWithClosedFeesAndFinesAnonymizedAfterFeeFineCloseIntervalPassed.

/**
 * Scenario 6
 *
 *     Given:
 *         An Anonymize closed loans setting of "X interval after loan closes"
 *         An Anonymize closed loans with associated fees/fines setting of
 *         "X interval after fee/fine closes"
 *         A closed loan with an associated fee/fine
 *     When all fees/fines associated with the loan are closed, and X
 *     interval after the fee/fine closes has passed
 *     Then anonymize the loan
 */
@Test
void testClosedLoansWithClosedFeesAndFinesAnonymizedAfterFeeFineCloseIntervalPassed() {
    LoanHistoryConfigurationBuilder loanHistoryConfig = new LoanHistoryConfigurationBuilder().loanCloseAnonymizeAfterXInterval(1, "minute").feeFineCloseAnonymizeAfterXInterval(20, "minute");
    createConfiguration(loanHistoryConfig);
    IndividualResource loanResource = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item1).to(user).at(servicePoint.getId()));
    UUID loanID = loanResource.getId();
    createClosedAccountWithFeeFines(loanResource, getZonedDateTime());
    createClosedAccountWithFeeFines(loanResource, getZonedDateTime());
    checkInFixture.checkInByBarcode(item1);
    mockClockManagerToReturnFixedDateTime(getZonedDateTime().plus(20 * ONE_MINUTE_AND_ONE_MILLIS, ChronoUnit.MILLIS));
    anonymizeLoansInTenant();
    assertThat(loansStorageClient.getById(loanID).getJson(), isAnonymized());
    assertThatPublishedAnonymizeLoanLogRecordEventsAreValid(loansClient.getById(loanID).getJson());
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) LoanHistoryConfigurationBuilder(api.support.builders.LoanHistoryConfigurationBuilder) Test(org.junit.jupiter.api.Test)

Example 3 with LoanHistoryConfigurationBuilder

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

the class AnonymizeLoansAfterXIntervalTests method testNeverAnonymizeClosedLoansWithAssociatedFeeFines.

/**
 * Scenario 7
 *
 *     Given:
 *         An Anonymize closed loans setting of "X interval after loan closes"
 *         An Anonymize closed loans with associated fees/fines setting of
 *         "Never"
 *         An open loan with an associated fee/fine
 *     When the item in the loan is checked in
 *     Then do not anonymize the loan
 */
@Test
void testNeverAnonymizeClosedLoansWithAssociatedFeeFines() {
    LoanHistoryConfigurationBuilder loanHistoryConfig = new LoanHistoryConfigurationBuilder().loanCloseAnonymizeAfterXInterval(1, "minute").feeFineCloseAnonymizeNever();
    createConfiguration(loanHistoryConfig);
    IndividualResource loanResource = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item1).to(user).at(servicePoint.getId()));
    UUID loanID = loanResource.getId();
    createClosedAccountWithFeeFines(loanResource, getZonedDateTime());
    checkInFixture.checkInByBarcode(item1);
    anonymizeLoansInTenant();
    assertThat(loansStorageClient.getById(loanID).getJson(), not(isAnonymized()));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) LoanHistoryConfigurationBuilder(api.support.builders.LoanHistoryConfigurationBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with LoanHistoryConfigurationBuilder

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

the class AnonymizeLoansAfterXIntervalTests method testOpenLoansWithFeesAndFinesNotAnonymizedAfterFeeFineCloseIntervalNotPassed.

/**
 * Scenario 4
 *
 *     Given:
 *         An Anonymize closed loans setting of "X interval after loan closes"
 *         An Anonymize closed loans with associated fees/fines setting of
 *         "X interval after fee/fine closes"
 *         An open loan with an associated fee/fine
 *     When the item in the loan is checked in
 *     Then do not anonymize the loan
 */
@Test
void testOpenLoansWithFeesAndFinesNotAnonymizedAfterFeeFineCloseIntervalNotPassed() {
    LoanHistoryConfigurationBuilder loanHistoryConfig = new LoanHistoryConfigurationBuilder().loanCloseAnonymizeAfterXInterval(1, "minute").feeFineCloseAnonymizeAfterXInterval(20, "minutes");
    createConfiguration(loanHistoryConfig);
    IndividualResource loanResource = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item1).to(user).at(servicePoint.getId()));
    UUID loanID = loanResource.getId();
    createClosedAccountWithFeeFines(loanResource, getZonedDateTime());
    checkInFixture.checkInByBarcode(item1);
    anonymizeLoansInTenant();
    assertThat(loansStorageClient.getById(loanID).getJson(), not(isAnonymized()));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) LoanHistoryConfigurationBuilder(api.support.builders.LoanHistoryConfigurationBuilder) Test(org.junit.jupiter.api.Test)

Example 5 with LoanHistoryConfigurationBuilder

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

the class AnonymizeLoansAfterXIntervalTests method testNeverAnonymizeClosedLoansWithAssociatedFeeFinesAfterAfterIntervalPassed.

/**
 * Scenario 8
 *
 *     Given:
 *         An Anonymize closed loans setting of "X interval after loan closes"
 *         An Anonymize closed loans with associated fees/fines setting of
 *         "Never"
 *         An open loan with an associated fee/fine
 *     When X interval has elapsed after the loan closed
 *     Then do not anonymize the loan
 */
@Test
void testNeverAnonymizeClosedLoansWithAssociatedFeeFinesAfterAfterIntervalPassed() {
    LoanHistoryConfigurationBuilder loanHistoryConfig = new LoanHistoryConfigurationBuilder().loanCloseAnonymizeAfterXInterval(1, "minute").feeFineCloseAnonymizeNever();
    createConfiguration(loanHistoryConfig);
    IndividualResource loanResource = checkOutFixture.checkOutByBarcode(new CheckOutByBarcodeRequestBuilder().forItem(item1).to(user).at(servicePoint.getId()));
    UUID loanID = loanResource.getId();
    createClosedAccountWithFeeFines(loanResource, getZonedDateTime());
    checkInFixture.checkInByBarcode(item1);
    mockClockManagerToReturnFixedDateTime(getZonedDateTime().plus(ONE_MINUTE_AND_ONE_MILLIS, ChronoUnit.MILLIS));
    anonymizeLoansInTenant();
    assertThat(loansStorageClient.getById(loanID).getJson(), not(isAnonymized()));
}
Also used : CheckOutByBarcodeRequestBuilder(api.support.builders.CheckOutByBarcodeRequestBuilder) IndividualResource(api.support.http.IndividualResource) UUID(java.util.UUID) LoanHistoryConfigurationBuilder(api.support.builders.LoanHistoryConfigurationBuilder) Test(org.junit.jupiter.api.Test)

Aggregations

CheckOutByBarcodeRequestBuilder (api.support.builders.CheckOutByBarcodeRequestBuilder)30 LoanHistoryConfigurationBuilder (api.support.builders.LoanHistoryConfigurationBuilder)30 IndividualResource (api.support.http.IndividualResource)30 UUID (java.util.UUID)30 Test (org.junit.jupiter.api.Test)30