FINERACT-2413: Improve re-amortization undo validation
This commit is contained in:
committed by
Arnold Gálovics
parent
b457b2aa93
commit
2858316c71
+4
-41
@@ -185,53 +185,16 @@ class LoanReAmortizationValidatorTest {
|
||||
List<LoanTransaction> transactions = List.of(loanTransaction(LoanTransactionType.DISBURSEMENT, actualDate.minusDays(3)));
|
||||
Loan loan = loan();
|
||||
given(loan.getLoanTransactions()).willReturn(transactions);
|
||||
JsonCommand command = jsonCommand();
|
||||
// when
|
||||
GeneralPlatformDomainRuleException result = assertThrows(GeneralPlatformDomainRuleException.class,
|
||||
() -> underTest.validateUndoReAmortize(loan, command));
|
||||
() -> underTest.findAndValidateReAmortizeTransactionForUndo(loan));
|
||||
// then
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getGlobalisationMessageCode()).isEqualTo("error.msg.loan.reamortize.reamortization.transaction.missing");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateUndoReAmortize_ShouldThrowException_WhenLoanAlreadyHasRepaymentAfterReAmortization() {
|
||||
// given
|
||||
List<LoanTransaction> transactions = List.of(loanTransaction(LoanTransactionType.DISBURSEMENT, actualDate.minusDays(3)),
|
||||
loanTransaction(LoanTransactionType.REAMORTIZE, actualDate.minusDays(2)),
|
||||
loanTransaction(LoanTransactionType.REPAYMENT, actualDate.minusDays(1)));
|
||||
Loan loan = loan();
|
||||
given(loan.getLoanTransactions()).willReturn(transactions);
|
||||
JsonCommand command = jsonCommand();
|
||||
// when
|
||||
GeneralPlatformDomainRuleException result = assertThrows(GeneralPlatformDomainRuleException.class,
|
||||
() -> underTest.validateUndoReAmortize(loan, command));
|
||||
// then
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getGlobalisationMessageCode()).isEqualTo("error.msg.loan.reamortize.repayment.exists.after.reamortization");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateUndoReAmortize_ShouldThrowException_WhenLoanAlreadyHasRepaymentAfterReAmortization_SameDay() {
|
||||
// given
|
||||
List<LoanTransaction> transactions = List.of(loanTransaction(LoanTransactionType.DISBURSEMENT, actualDate.minusDays(2)),
|
||||
loanTransaction(LoanTransactionType.REAMORTIZE, actualDate.minusDays(1),
|
||||
OffsetDateTime.of(actualDate, LocalTime.of(10, 0), ZoneOffset.UTC)),
|
||||
loanTransaction(LoanTransactionType.REPAYMENT, actualDate.minusDays(1),
|
||||
OffsetDateTime.of(actualDate, LocalTime.of(11, 0), ZoneOffset.UTC)));
|
||||
Loan loan = loan();
|
||||
given(loan.getLoanTransactions()).willReturn(transactions);
|
||||
JsonCommand command = jsonCommand();
|
||||
// when
|
||||
GeneralPlatformDomainRuleException result = assertThrows(GeneralPlatformDomainRuleException.class,
|
||||
() -> underTest.validateUndoReAmortize(loan, command));
|
||||
// then
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getGlobalisationMessageCode()).isEqualTo("error.msg.loan.reamortize.repayment.exists.after.reamortization");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateUndoReAmortize_ShouldNotThrowException_WhenLoanAlreadyHasRepaymentAfterReAmortization_SameDay_RepaymentBeforeReAmortization() {
|
||||
public void testValidateUndoReAmortize_ShouldNotThrowException() {
|
||||
// given
|
||||
List<LoanTransaction> transactions = List.of(loanTransaction(LoanTransactionType.DISBURSEMENT, actualDate.minusDays(2)),
|
||||
loanTransaction(LoanTransactionType.REAMORTIZE, actualDate.minusDays(1),
|
||||
@@ -240,9 +203,8 @@ class LoanReAmortizationValidatorTest {
|
||||
OffsetDateTime.of(actualDate, LocalTime.of(9, 0), ZoneOffset.UTC)));
|
||||
Loan loan = loan();
|
||||
given(loan.getLoanTransactions()).willReturn(transactions);
|
||||
JsonCommand command = jsonCommand();
|
||||
// when
|
||||
underTest.validateUndoReAmortize(loan, command);
|
||||
underTest.findAndValidateReAmortizeTransactionForUndo(loan);
|
||||
// then no exception thrown
|
||||
}
|
||||
|
||||
@@ -271,6 +233,7 @@ class LoanReAmortizationValidatorTest {
|
||||
given(loanTransaction.getTypeOf()).willReturn(type);
|
||||
given(loanTransaction.getTransactionDate()).willReturn(txDate);
|
||||
given(loanTransaction.getSubmittedOnDate()).willReturn(txDate);
|
||||
given(loanTransaction.isNotReversed()).willReturn(true);
|
||||
return loanTransaction;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user