alberto-art3ch commented on code in PR #3856:
URL: https://github.com/apache/fineract/pull/3856#discussion_r1562546899
##########
fineract-provider/src/test/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStepTest.java:
##########
@@ -175,4 +182,53 @@ public void
givenLoanWithInstallmentOverdueAfterConfiguredDaysInLoanProductWhenS
assertEquals(repaymentInstallment, loanPayloadForEvent);
assertEquals(processedLoan, loanForProcessing);
}
+
+ @Test
+ public void
givenActiveLoanWithZeroOutstandingWhenStepExecutionThenNoBusinessEventIsRaised()
{
+ // given
+
when(configurationDomainService.retrieveRepaymentOverdueDays()).thenReturn(2L);
+ LocalDate loanInstallmentRepaymentDueDateBefore5Days =
DateUtils.getBusinessLocalDate().minusDays(1);
+ Loan loanForProcessing = Mockito.mock(Loan.class);
+ LoanProduct loanProduct = Mockito.mock(LoanProduct.class);
+ LoanSummary loanSummary = Mockito.mock(LoanSummary.class);
+ List<LoanRepaymentScheduleInstallment>
loanRepaymentScheduleInstallments = Arrays
+ .asList(new
LoanRepaymentScheduleInstallment(loanForProcessing, 1,
LocalDate.now(ZoneId.systemDefault()),
+ loanInstallmentRepaymentDueDateBefore5Days,
BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
+ BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
false, new HashSet<>(), BigDecimal.valueOf(0.0)));
+ when(loanForProcessing.getLoanProduct()).thenReturn(loanProduct);
+ when(loanProduct.getOverDueDaysForRepaymentEvent()).thenReturn(1);
+ when(loanForProcessing.getLoanSummary()).thenReturn(loanSummary);
+
when(loanForProcessing.getLoanSummary().getTotalOutstanding()).thenReturn(BigDecimal.ZERO);
+
when(loanForProcessing.getRepaymentScheduleInstallments()).thenReturn(loanRepaymentScheduleInstallments);
+ // when
+ Loan processedLoan = underTest.execute(loanForProcessing);
+ // then - No Business Event raised
+ verify(businessEventNotifierService,
times(0)).notifyPostBusinessEvent(any());
+ assertEquals(processedLoan, loanForProcessing);
+ }
+
+ @Test
+ public void
givenActiveLoanWithNonZeroOutstandingWhenStepExecutionThenBusinessEventIsRaised()
{
Review Comment:
Done! Unit Test created:
`givenSubmittedLoanWhenStepExecutionThenNoBusinessEventIsRaised`
`givenApprovedLoanWhenStepExecutionThenNoBusinessEventIsRaised`
##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStep.java:
##########
@@ -71,4 +79,12 @@ public String getEnumStyledName() {
public String getHumanReadableName() {
return "Check loan repayment overdue";
}
+
+ private static boolean isOverDueEventNeededToBeSent(Loan loan, Long
numberOfDaysBeforeDueDateToRaiseEvent, LocalDate currentDate,
+ LoanRepaymentScheduleInstallment repaymentScheduleInstallment,
LocalDate repaymentDate) {
+ return
repaymentDate.plusDays(numberOfDaysBeforeDueDateToRaiseEvent).equals(currentDate)
+ &&
loan.getLoanSummary().getTotalOutstanding().compareTo(BigDecimal.ZERO) > 0
Review Comment:
Done!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]