FINERACT-2181: Improve AssertJ assertions in DefaultScheduledDateGeneratorTest
This commit is contained in:
+46
-48
@@ -18,15 +18,18 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.domain;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -41,17 +44,15 @@ import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType;
|
||||
import org.apache.fineract.portfolio.charge.domain.ChargePaymentMode;
|
||||
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
public class SingleLoanChargeRepaymentScheduleProcessingWrapperTest {
|
||||
|
||||
private final SingleLoanChargeRepaymentScheduleProcessingWrapper underTest = new SingleLoanChargeRepaymentScheduleProcessingWrapper();
|
||||
private static final MockedStatic<MoneyHelper> MONEY_HELPER = Mockito.mockStatic(MoneyHelper.class);
|
||||
private static final MockedStatic<MoneyHelper> MONEY_HELPER = mockStatic(MoneyHelper.class);
|
||||
|
||||
private MonetaryCurrency currency = MonetaryCurrency.fromCurrencyData(new CurrencyData("USD"));
|
||||
|
||||
@@ -70,65 +71,63 @@ public class SingleLoanChargeRepaymentScheduleProcessingWrapperTest {
|
||||
|
||||
@Test
|
||||
public void testOnePeriodWithFeeCharge() {
|
||||
LocalDate disbursementDate = LocalDate.of(2023, 01, 1);
|
||||
ThreadLocalContextUtil.setBusinessDates(new HashMap<>(Map.of(BusinessDateType.BUSINESS_DATE, disbursementDate)));
|
||||
LocalDate disbursementDate = LocalDate.of(2023, 1, 1);
|
||||
ThreadLocalContextUtil.setBusinessDates(new HashMap<>(new EnumMap<>(Map.of(BusinessDateType.BUSINESS_DATE, disbursementDate))));
|
||||
|
||||
LoanRepaymentScheduleInstallment period = createPeriod(1, LocalDate.of(2023, 01, 1), LocalDate.of(2023, 01, 30));
|
||||
LoanCharge loanCharge = createCharge(false);
|
||||
LoanRepaymentScheduleInstallment period = createPeriod(1, LocalDate.of(2023, 1, 1), LocalDate.of(2023, 1, 30));
|
||||
underTest.reprocess(currency, disbursementDate, List.of(period), createCharge(false));
|
||||
|
||||
underTest.reprocess(currency, disbursementDate, List.of(period), loanCharge);
|
||||
|
||||
verify(period, "10.0", "0.0", "0.0", "0.0", "0.0", "0.0");
|
||||
customVerify(period, "10.0", "0.0", "0.0", "0.0", "0.0", "0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnePeriodWithPenaltyCharge() {
|
||||
LocalDate disbursementDate = LocalDate.of(2023, 01, 1);
|
||||
ThreadLocalContextUtil.setBusinessDates(new HashMap<>(Map.of(BusinessDateType.BUSINESS_DATE, disbursementDate)));
|
||||
LocalDate disbursementDate = LocalDate.of(2023, 1, 1);
|
||||
ThreadLocalContextUtil.setBusinessDates(new HashMap<>(new EnumMap<>(Map.of(BusinessDateType.BUSINESS_DATE, disbursementDate))));
|
||||
|
||||
LoanRepaymentScheduleInstallment period = createPeriod(1, LocalDate.of(2023, 01, 1), LocalDate.of(2023, 01, 30));
|
||||
LoanCharge loanCharge = createCharge(true);
|
||||
LoanRepaymentScheduleInstallment period = createPeriod(1, LocalDate.of(2023, 1, 1), LocalDate.of(2023, 1, 30));
|
||||
underTest.reprocess(currency, disbursementDate, List.of(period), createCharge(true));
|
||||
|
||||
underTest.reprocess(currency, disbursementDate, List.of(period), loanCharge);
|
||||
|
||||
verify(period, "0.0", "0.0", "0.0", "10.0", "0.0", "0.0");
|
||||
customVerify(period, "0.0", "0.0", "0.0", "10.0", "0.0", "0.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoPeriodsWithPenaltyCharge() {
|
||||
LocalDate disbursementDate = LocalDate.of(2023, 01, 1);
|
||||
ThreadLocalContextUtil.setBusinessDates(new HashMap<>(Map.of(BusinessDateType.BUSINESS_DATE, disbursementDate)));
|
||||
LocalDate disbursementDate = LocalDate.of(2023, 1, 1);
|
||||
ThreadLocalContextUtil.setBusinessDates(new HashMap<>(new EnumMap<>(Map.of(BusinessDateType.BUSINESS_DATE, disbursementDate))));
|
||||
|
||||
LoanRepaymentScheduleInstallment period1 = createPeriod(1, LocalDate.of(2023, 01, 1), LocalDate.of(2023, 01, 31));
|
||||
LoanRepaymentScheduleInstallment period2 = createPeriod(1, LocalDate.of(2023, 02, 1), LocalDate.of(2023, 02, 28));
|
||||
LoanRepaymentScheduleInstallment period1 = createPeriod(1, LocalDate.of(2023, 1, 1), LocalDate.of(2023, 1, 31));
|
||||
LoanRepaymentScheduleInstallment period2 = createPeriod(1, LocalDate.of(2023, 2, 1), LocalDate.of(2023, 2, 28));
|
||||
|
||||
LoanCharge loanCharge = createCharge(true);
|
||||
underTest.reprocess(currency, disbursementDate, List.of(period1, period2), createCharge(true));
|
||||
|
||||
underTest.reprocess(currency, disbursementDate, List.of(period1, period2), loanCharge);
|
||||
|
||||
verify(period1, "0.0", "0.0", "0.0", "10.0", "0.0", "0.0");
|
||||
verify(period2, "0.0", "0.0", "0.0", "0.0", "0.0", "0.0");
|
||||
customVerify(period1, "0.0", "0.0", "0.0", "10.0", "0.0", "0.0");
|
||||
customVerify(period2, "0.0", "0.0", "0.0", "0.0", "0.0", "0.0");
|
||||
}
|
||||
|
||||
private void verify(LoanRepaymentScheduleInstallment period, String expectedFeeChargesDue, String expectedFeeChargesWaived,
|
||||
private void customVerify(LoanRepaymentScheduleInstallment period, String expectedFeeChargesDue, String expectedFeeChargesWaived,
|
||||
String expectedFeeChargesWrittenOff, String expectedPenaltyChargesDue, String expectedPenaltyChargesWaived,
|
||||
String expectedPenaltyChargesWrittenOff) {
|
||||
|
||||
Mockito.verify(period, times(1)).addToChargePortion(feeChargesDue.capture(), feeChargesWaived.capture(),
|
||||
feeChargesWrittenOff.capture(), penaltyChargesDue.capture(), penaltyChargesWaived.capture(),
|
||||
penaltyChargesWrittenOff.capture());
|
||||
verify(period, times(1)).addToChargePortion(feeChargesDue.capture(), feeChargesWaived.capture(), feeChargesWrittenOff.capture(),
|
||||
penaltyChargesDue.capture(), penaltyChargesWaived.capture(), penaltyChargesWrittenOff.capture());
|
||||
|
||||
Assertions.assertTrue(new BigDecimal(expectedFeeChargesDue).compareTo(feeChargesDue.getValue().getAmount()) == 0);
|
||||
Assertions.assertTrue(new BigDecimal(expectedFeeChargesWaived).compareTo(feeChargesWaived.getValue().getAmount()) == 0);
|
||||
Assertions.assertTrue(new BigDecimal(expectedFeeChargesWrittenOff).compareTo(feeChargesWrittenOff.getValue().getAmount()) == 0);
|
||||
Assertions.assertTrue(new BigDecimal(expectedPenaltyChargesDue).compareTo(penaltyChargesDue.getValue().getAmount()) == 0);
|
||||
Assertions.assertTrue(new BigDecimal(expectedPenaltyChargesWaived).compareTo(penaltyChargesWaived.getValue().getAmount()) == 0);
|
||||
Assertions.assertTrue(
|
||||
new BigDecimal(expectedPenaltyChargesWrittenOff).compareTo(penaltyChargesWrittenOff.getValue().getAmount()) == 0);
|
||||
assertEquals(new BigDecimal(expectedFeeChargesDue).setScale(1, RoundingMode.UNNECESSARY),
|
||||
feeChargesDue.getValue().getAmount().setScale(1, RoundingMode.UNNECESSARY));
|
||||
assertEquals(new BigDecimal(expectedFeeChargesWaived).setScale(1, RoundingMode.UNNECESSARY),
|
||||
feeChargesWaived.getValue().getAmount().setScale(1, RoundingMode.UNNECESSARY));
|
||||
assertEquals(new BigDecimal(expectedFeeChargesWrittenOff).setScale(1, RoundingMode.UNNECESSARY),
|
||||
feeChargesWrittenOff.getValue().getAmount().setScale(1, RoundingMode.UNNECESSARY));
|
||||
assertEquals(new BigDecimal(expectedPenaltyChargesDue).setScale(1, RoundingMode.UNNECESSARY),
|
||||
penaltyChargesDue.getValue().getAmount().setScale(1, RoundingMode.UNNECESSARY));
|
||||
assertEquals(new BigDecimal(expectedPenaltyChargesWaived).setScale(1, RoundingMode.UNNECESSARY),
|
||||
penaltyChargesWaived.getValue().getAmount().setScale(1, RoundingMode.UNNECESSARY));
|
||||
assertEquals(new BigDecimal(expectedPenaltyChargesWrittenOff).setScale(1, RoundingMode.UNNECESSARY),
|
||||
penaltyChargesWrittenOff.getValue().getAmount().setScale(1, RoundingMode.UNNECESSARY));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static LoanCharge createCharge(boolean penalty) {
|
||||
private LoanCharge createCharge(boolean penalty) {
|
||||
Charge charge = mock(Charge.class);
|
||||
when(charge.getId()).thenReturn(1L);
|
||||
when(charge.getName()).thenReturn("charge a");
|
||||
@@ -136,23 +135,22 @@ public class SingleLoanChargeRepaymentScheduleProcessingWrapperTest {
|
||||
when(charge.isPenalty()).thenReturn(penalty);
|
||||
Loan loan = mock(Loan.class);
|
||||
when(loan.isInterestBearing()).thenReturn(false);
|
||||
LoanCharge loanCharge = new LoanCharge(loan, charge, new BigDecimal(1000), new BigDecimal(10), ChargeTimeType.SPECIFIED_DUE_DATE,
|
||||
ChargeCalculationType.FLAT, LocalDate.of(2023, 01, 15), ChargePaymentMode.REGULAR, 1, null, null);
|
||||
return loanCharge;
|
||||
return new LoanCharge(loan, charge, new BigDecimal(1000), new BigDecimal(10), ChargeTimeType.SPECIFIED_DUE_DATE,
|
||||
ChargeCalculationType.FLAT, LocalDate.of(2023, 1, 15), ChargePaymentMode.REGULAR, 1, null, null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private LoanRepaymentScheduleInstallment createPeriod(int periodId, LocalDate start, LocalDate end) {
|
||||
LoanRepaymentScheduleInstallment period = Mockito.mock(LoanRepaymentScheduleInstallment.class);
|
||||
LoanRepaymentScheduleInstallment period = mock(LoanRepaymentScheduleInstallment.class);
|
||||
MathContext mc = new MathContext(12, RoundingMode.HALF_EVEN);
|
||||
Mockito.when(period.getInstallmentNumber()).thenReturn(periodId);
|
||||
Mockito.when(period.getFromDate()).thenReturn(start);
|
||||
Mockito.when(period.getDueDate()).thenReturn(end);
|
||||
when(period.getInstallmentNumber()).thenReturn(periodId);
|
||||
when(period.getFromDate()).thenReturn(start);
|
||||
when(period.getDueDate()).thenReturn(end);
|
||||
Money principal = Money.of(currency, new BigDecimal("1000.0"), mc);
|
||||
Money interest = Money.of(currency, BigDecimal.ZERO, mc);
|
||||
|
||||
Mockito.when(period.getPrincipal(eq(currency))).thenReturn(principal);
|
||||
Mockito.when(period.getInterestCharged(eq(currency))).thenReturn(interest);
|
||||
when(period.getPrincipal(currency)).thenReturn(principal);
|
||||
when(period.getInterestCharged(currency)).thenReturn(interest);
|
||||
return period;
|
||||
}
|
||||
}
|
||||
|
||||
+34
-28
@@ -24,6 +24,7 @@ import java.time.OffsetDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData;
|
||||
@@ -33,6 +34,9 @@ import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@@ -57,10 +61,10 @@ public class ChangeOperationTest {
|
||||
ChangeOperation interestChange = createInterestRateChange("2023-10-17");
|
||||
ChangeOperation charge = createCharge("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
ChangeOperation transaction = createTransaction("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
Assertions.assertTrue(interestChange.compareTo(transaction) < 0);
|
||||
Assertions.assertTrue(interestChange.compareTo(charge) < 0);
|
||||
Assertions.assertTrue(charge.compareTo(transaction) == 0);
|
||||
Assertions.assertTrue(transaction.compareTo(charge) == 0);
|
||||
Assertions.assertEquals(-1, interestChange.compareTo(transaction));
|
||||
Assertions.assertEquals(-1, interestChange.compareTo(charge));
|
||||
Assertions.assertEquals(0, charge.compareTo(transaction));
|
||||
Assertions.assertEquals(0, transaction.compareTo(charge));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,34 +72,37 @@ public class ChangeOperationTest {
|
||||
ChangeOperation interestChange = createInterestRateChange("2023-10-17");
|
||||
ChangeOperation charge = createCharge("2023-10-16", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
ChangeOperation transaction = createTransaction("2023-10-16", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
Assertions.assertTrue(interestChange.compareTo(transaction) > 0);
|
||||
Assertions.assertTrue(interestChange.compareTo(charge) > 0);
|
||||
Assertions.assertTrue(charge.compareTo(transaction) == 0);
|
||||
Assertions.assertTrue(transaction.compareTo(charge) == 0);
|
||||
Assertions.assertEquals(1, interestChange.compareTo(transaction));
|
||||
Assertions.assertEquals(1, interestChange.compareTo(charge));
|
||||
Assertions.assertEquals(0, charge.compareTo(transaction));
|
||||
Assertions.assertEquals(0, transaction.compareTo(charge));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareToCreatedDateTime() {
|
||||
ChangeOperation charge = createCharge("2023-10-17", "2023-10-17", "2023-10-17T10:15:31+01:00");
|
||||
ChangeOperation transaction = createTransaction("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
Assertions.assertTrue(charge.compareTo(transaction) > 0);
|
||||
Assertions.assertTrue(transaction.compareTo(charge) < 0);
|
||||
@ParameterizedTest
|
||||
@MethodSource("provideComparisonTestData")
|
||||
public void testComparison(String chargeEffectiveDate, String chargeSubmittedDate, String chargeCreationDateTime,
|
||||
String transactionDate, String transactionSubmittedDate, String transactionCreationDateTime, int expectedChargeVsTransaction,
|
||||
int expectedTransactionVsCharge) {
|
||||
ChangeOperation charge = createCharge(chargeEffectiveDate, chargeSubmittedDate, chargeCreationDateTime);
|
||||
ChangeOperation transaction = createTransaction(transactionDate, transactionSubmittedDate, transactionCreationDateTime);
|
||||
|
||||
Assertions.assertEquals(expectedChargeVsTransaction, charge.compareTo(transaction));
|
||||
Assertions.assertEquals(expectedTransactionVsCharge, transaction.compareTo(charge));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareToSubmittedOnDate() {
|
||||
ChangeOperation charge = createCharge("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
ChangeOperation transaction = createTransaction("2023-10-17", "2023-10-16", "2023-10-17T10:15:30+01:00");
|
||||
Assertions.assertTrue(charge.compareTo(transaction) > 0);
|
||||
Assertions.assertTrue(transaction.compareTo(charge) < 0);
|
||||
}
|
||||
private static Stream<Arguments> provideComparisonTestData() {
|
||||
return Stream.of(
|
||||
// Test case for createdDateTime comparison
|
||||
Arguments.of("2023-10-17", "2023-10-17", "2023-10-17T10:15:31+01:00", "2023-10-17", "2023-10-17",
|
||||
"2023-10-17T10:15:30+01:00", 1, -1),
|
||||
|
||||
@Test
|
||||
public void testComparatorEffectiveDate() {
|
||||
ChangeOperation charge = createCharge("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
ChangeOperation transaction = createTransaction("2023-10-16", "2023-10-17", "2023-10-17T10:15:30+01:00");
|
||||
Assertions.assertTrue(charge.compareTo(transaction) > 0);
|
||||
Assertions.assertTrue(transaction.compareTo(charge) < 0);
|
||||
// Test case for submittedOnDate comparison
|
||||
Arguments.of("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00", "2023-10-17", "2023-10-16",
|
||||
"2023-10-17T10:15:30+01:00", 1, -1),
|
||||
|
||||
// Test case for effectiveDate comparison
|
||||
Arguments.of("2023-10-17", "2023-10-17", "2023-10-17T10:15:30+01:00", "2023-10-16", "2023-10-17",
|
||||
"2023-10-17T10:15:30+01:00", 1, -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,5 +162,4 @@ public class ChangeOperationTest {
|
||||
Mockito.when(transaction.getCreatedDate()).thenReturn(Optional.of(OffsetDateTime.parse(creationDateTime)));
|
||||
return new ChangeOperation(transaction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-3
@@ -28,7 +28,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -214,8 +213,13 @@ class AdvancedPaymentAllocationsValidatorTest {
|
||||
|
||||
@NotNull
|
||||
private static List<Pair<Integer, PaymentAllocationType>> createPaymentAllocationTypeList() {
|
||||
AtomicInteger i = new AtomicInteger(1);
|
||||
return EnumSet.allOf(PaymentAllocationType.class).stream().map(p -> Pair.of(i.getAndIncrement(), p)).toList();
|
||||
return EnumSet.allOf(PaymentAllocationType.class).stream().map(p -> {
|
||||
try {
|
||||
return Pair.of(Integer.parseInt(String.valueOf(Integer.parseInt(String.valueOf(p.ordinal())) + 1)), p);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("Failed to create payment allocation type list", e);
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
private void assertPlatformException(String expectedMessage, String expectedCode,
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ class LoanItemReaderTest {
|
||||
}
|
||||
executorService.shutdown();
|
||||
boolean b = executorService.awaitTermination(5L, TimeUnit.SECONDS);
|
||||
Assertions.assertTrue(b, "Executor did not terminate successfully");
|
||||
Assertions.assertEquals(true, b, "Executor did not terminate successfully");
|
||||
|
||||
// verify that this was called 100times, and for each loan it was called exactly once
|
||||
for (long i = 1; i <= 100; i++) {
|
||||
|
||||
+38
-31
@@ -105,19 +105,28 @@ public class DefaultScheduledDateGeneratorTest {
|
||||
loanApplicationTerms, holidayDetailDTO);
|
||||
|
||||
// then
|
||||
assertThat(result.size()).isEqualTo(4);
|
||||
assertThat(result.get(0).periodNumber()).isEqualTo(1);
|
||||
assertThat(result.get(0).periodFromDate().toString()).isEqualTo("2024-01-01");
|
||||
assertThat(result.get(0).periodDueDate().toString()).isEqualTo("2024-02-01");
|
||||
assertThat(result.get(1).periodNumber()).isEqualTo(2);
|
||||
assertThat(result.get(1).periodFromDate().toString()).isEqualTo("2024-02-01");
|
||||
assertThat(result.get(1).periodDueDate().toString()).isEqualTo("2024-03-01");
|
||||
assertThat(result.get(2).periodNumber()).isEqualTo(3);
|
||||
assertThat(result.get(2).periodFromDate().toString()).isEqualTo("2024-03-01");
|
||||
assertThat(result.get(2).periodDueDate().toString()).isEqualTo("2024-04-01");
|
||||
assertThat(result.get(3).periodNumber()).isEqualTo(4);
|
||||
assertThat(result.get(3).periodFromDate().toString()).isEqualTo("2024-04-01");
|
||||
assertThat(result.get(3).periodDueDate().toString()).isEqualTo("2024-05-01");
|
||||
assertThat(result).hasSize(4);
|
||||
assertThat(result).satisfies(periods -> {
|
||||
LoanScheduleModelPeriod firstPeriod = periods.get(0);
|
||||
assertThat(firstPeriod.periodNumber()).isEqualTo(1);
|
||||
assertThat(firstPeriod.periodFromDate()).hasToString("2024-01-01");
|
||||
assertThat(firstPeriod.periodDueDate()).hasToString("2024-02-01");
|
||||
|
||||
LoanScheduleModelPeriod secondPeriod = periods.get(1);
|
||||
assertThat(secondPeriod.periodNumber()).isEqualTo(2);
|
||||
assertThat(secondPeriod.periodFromDate()).hasToString("2024-02-01");
|
||||
assertThat(secondPeriod.periodDueDate()).hasToString("2024-03-01");
|
||||
|
||||
LoanScheduleModelPeriod thirdPeriod = periods.get(2);
|
||||
assertThat(thirdPeriod.periodNumber()).isEqualTo(3);
|
||||
assertThat(thirdPeriod.periodFromDate()).hasToString("2024-03-01");
|
||||
assertThat(thirdPeriod.periodDueDate()).hasToString("2024-04-01");
|
||||
|
||||
LoanScheduleModelPeriod fourthPeriod = periods.get(3);
|
||||
assertThat(fourthPeriod.periodNumber()).isEqualTo(4);
|
||||
assertThat(fourthPeriod.periodFromDate()).hasToString("2024-04-01");
|
||||
assertThat(fourthPeriod.periodDueDate()).hasToString("2024-05-01");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -126,17 +135,17 @@ public class DefaultScheduledDateGeneratorTest {
|
||||
@WithSystemProperty(key = FLOATING_TIMEZONE_PROPERTY_KEY, value = "true")
|
||||
public void test_AdjustRepaymentDate_Works_WithSameTenant_And_SystemTimeZone() {
|
||||
// given
|
||||
HolidayDetailDTO holidayDetailDTO = createHolidayDTO();
|
||||
|
||||
LocalDate dueRepaymentPeriodDate = LocalDate.of(2023, 11, 26);
|
||||
|
||||
LoanApplicationTerms loanApplicationTerms = createLoanApplicationTerms(dueRepaymentPeriodDate, holidayDetailDTO);
|
||||
LoanApplicationTerms loanApplicationTerms = createLoanApplicationTerms(dueRepaymentPeriodDate, createHolidayDTO());
|
||||
// when
|
||||
AdjustedDateDetailsDTO result = underTest.adjustRepaymentDate(dueRepaymentPeriodDate, loanApplicationTerms, holidayDetailDTO);
|
||||
AdjustedDateDetailsDTO result = underTest.adjustRepaymentDate(dueRepaymentPeriodDate, loanApplicationTerms, createHolidayDTO());
|
||||
// then
|
||||
assertThat(result.getChangedScheduleDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(result.getChangedActualRepaymentDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(result.getNextRepaymentPeriodDueDate()).isEqualTo(LocalDate.of(2023, 12, 26));
|
||||
assertThat(result).satisfies(r -> {
|
||||
assertThat(r.getChangedScheduleDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(r.getChangedActualRepaymentDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(r.getNextRepaymentPeriodDueDate()).isEqualTo(LocalDate.of(2023, 12, 26));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,17 +154,17 @@ public class DefaultScheduledDateGeneratorTest {
|
||||
@WithSystemProperty(key = FLOATING_TIMEZONE_PROPERTY_KEY, value = "true")
|
||||
public void test_AdjustRepaymentDate_Works_WithDifferentTenant_And_SystemTimeZone() {
|
||||
// given
|
||||
HolidayDetailDTO holidayDetailDTO = createHolidayDTO();
|
||||
|
||||
LocalDate dueRepaymentPeriodDate = LocalDate.of(2023, 11, 26);
|
||||
|
||||
LoanApplicationTerms loanApplicationTerms = createLoanApplicationTerms(dueRepaymentPeriodDate, holidayDetailDTO);
|
||||
LoanApplicationTerms loanApplicationTerms = createLoanApplicationTerms(dueRepaymentPeriodDate, createHolidayDTO());
|
||||
// when
|
||||
AdjustedDateDetailsDTO result = underTest.adjustRepaymentDate(dueRepaymentPeriodDate, loanApplicationTerms, holidayDetailDTO);
|
||||
AdjustedDateDetailsDTO result = underTest.adjustRepaymentDate(dueRepaymentPeriodDate, loanApplicationTerms, createHolidayDTO());
|
||||
// then
|
||||
assertThat(result.getChangedScheduleDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(result.getChangedActualRepaymentDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(result.getNextRepaymentPeriodDueDate()).isEqualTo(LocalDate.of(2023, 12, 26));
|
||||
assertThat(result).satisfies(r -> {
|
||||
assertThat(r.getChangedScheduleDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(r.getChangedActualRepaymentDate()).isEqualTo(LocalDate.of(2023, 11, 26));
|
||||
assertThat(r.getNextRepaymentPeriodDueDate()).isEqualTo(LocalDate.of(2023, 12, 26));
|
||||
});
|
||||
}
|
||||
|
||||
private LoanApplicationTerms createLoanApplicationTerms(LocalDate dueRepaymentPeriodDate, HolidayDetailDTO holidayDetailDTO) {
|
||||
@@ -174,10 +183,8 @@ public class DefaultScheduledDateGeneratorTest {
|
||||
}
|
||||
|
||||
private HolidayDetailDTO createHolidayDTO() {
|
||||
WorkingDays workingDays = new WorkingDays("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU", MOVE_TO_NEXT_WORKING_DAY.getValue(),
|
||||
return new HolidayDetailDTO(false, EMPTY_LIST,
|
||||
new WorkingDays("FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU", MOVE_TO_NEXT_WORKING_DAY.getValue(), false, false),
|
||||
false, false);
|
||||
HolidayDetailDTO holidayDetailDTO = new HolidayDetailDTO(false, EMPTY_LIST, workingDays, false, false);
|
||||
return holidayDetailDTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user