FINERACT-2090: Accruals rework

This commit is contained in:
Ruchi Dhamankar
2024-07-09 14:55:04 +02:00
committed by Adam Saghy
parent 3f4bbf3e14
commit 1b75c868ba
26 changed files with 1695 additions and 1485 deletions
@@ -40,7 +40,7 @@ import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
import org.apache.fineract.infrastructure.core.exception.MultiException;
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.service.LoanAccrualPlatformService;
import org.apache.fineract.portfolio.loanaccount.service.LoanAccrualsProcessingService;
import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -54,7 +54,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
public class AddPeriodicAccrualEntriesBusinessStepTest {
@Mock
private LoanAccrualPlatformService loanAccrualPlatformService;
private LoanAccrualsProcessingService loanAccrualsProcessingService;
private AddPeriodicAccrualEntriesBusinessStep underTest;
@@ -64,7 +64,7 @@ public class AddPeriodicAccrualEntriesBusinessStepTest {
ThreadLocalContextUtil.setActionContext(ActionContext.DEFAULT);
ThreadLocalContextUtil
.setBusinessDates(new HashMap<>(Map.of(BusinessDateType.BUSINESS_DATE, LocalDate.now(ZoneId.systemDefault()))));
underTest = new AddPeriodicAccrualEntriesBusinessStep(loanAccrualPlatformService);
underTest = new AddPeriodicAccrualEntriesBusinessStep(loanAccrualsProcessingService);
}
@AfterEach
@@ -79,7 +79,7 @@ public class AddPeriodicAccrualEntriesBusinessStepTest {
// when
final Loan processedLoan = underTest.execute(loanForProcessing);
// then
verify(loanAccrualPlatformService, times(1)).addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
verify(loanAccrualsProcessingService, times(1)).addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
assertEquals(processedLoan, loanForProcessing);
}
@@ -89,13 +89,13 @@ public class AddPeriodicAccrualEntriesBusinessStepTest {
final Long loanId = RandomUtils.nextLong();
final Loan loanForProcessing = Mockito.mock(Loan.class);
when(loanForProcessing.getId()).thenReturn(loanId);
doThrow(new MultiException(Collections.singletonList(new RuntimeException()))).when(loanAccrualPlatformService)
doThrow(new MultiException(Collections.singletonList(new RuntimeException()))).when(loanAccrualsProcessingService)
.addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
// when
final BusinessStepException businessStepException = Assert.assertThrows(BusinessStepException.class,
() -> underTest.execute(loanForProcessing));
// then
verify(loanAccrualPlatformService, times(1)).addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
verify(loanAccrualsProcessingService, times(1)).addPeriodicAccruals(any(LocalDate.class), eq(loanForProcessing));
assertEquals(String.format("Fail to process period accrual for loan id [%s]", loanId), businessStepException.getMessage());
}