FINERACT-2276: Deprecate findExistingTransactionIds and fetch only the ids from database instead

This commit is contained in:
mariiaKraievska
2025-05-26 11:40:10 +02:00
committed by Adam Saghy
parent 88105c3cac
commit 13e4c8b55d
19 changed files with 77 additions and 60 deletions
@@ -92,6 +92,7 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleIns
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionRepository;
import org.apache.fineract.portfolio.loanaccount.serialization.LoanChargeValidator;
import org.apache.fineract.portfolio.loanaccount.service.LoanBalanceService;
import org.apache.fineract.portfolio.loanaccount.service.LoanChargeReadPlatformService;
@@ -128,7 +129,8 @@ public class LoanAccountDelinquencyRangeEventSerializerTest {
private AvroDateTimeMapper mapper;
private final LoanChargeService loanChargeService = new LoanChargeService(mock(LoanChargeValidator.class),
mock(LoanTransactionProcessingService.class), mock(LoanLifecycleStateMachine.class), mock(LoanBalanceService.class));
mock(LoanTransactionProcessingService.class), mock(LoanLifecycleStateMachine.class), mock(LoanBalanceService.class),
mock(LoanTransactionRepository.class));
private MockedStatic<MoneyHelper> moneyHelper = Mockito.mockStatic(MoneyHelper.class);
@@ -234,7 +234,7 @@ class LoanAdjustmentServiceImplTest {
when(loan.getLoanTransactions()).thenReturn(loanTransactions);
// Mock methods called inside adjustExistingTransaction
when(loan.findExistingTransactionIds()).thenReturn(Collections.emptyList());
when(loanTransactionRepository.findTransactionIdsByLoan(loan)).thenReturn(Collections.emptyList());
when(loan.findExistingReversedTransactionIds()).thenReturn(Collections.emptyList());
doNothing().when(loanTransactionValidator).validateActivityNotBeforeClientOrGroupTransferDate(any(), any(), any());
when(loan.isClosedWrittenOff()).thenReturn(false);
@@ -279,7 +279,7 @@ class LoanAdjustmentServiceImplTest {
LoanTransaction unrelatedTransaction = mock(LoanTransaction.class);
// Mock methods called inside adjustExistingTransaction
when(loan.findExistingTransactionIds()).thenReturn(Collections.emptyList());
when(loanTransactionRepository.findTransactionIdsByLoan(loan)).thenReturn(Collections.emptyList());
when(loan.findExistingReversedTransactionIds()).thenReturn(Collections.emptyList());
doNothing().when(loanTransactionValidator).validateActivityNotBeforeClientOrGroupTransferDate(any(), any(), any());
when(loan.isClosedWrittenOff()).thenReturn(false);
@@ -192,7 +192,7 @@ class LoanChargeWritePlatformServiceImplTest {
when(loanAccountService.saveAndFlushLoanWithDataIntegrityViolationChecks(any())).thenReturn(loan);
List<Long> existingTransactionIds = new ArrayList<>();
List<Long> existingReversedTransactionIds = new ArrayList<>();
when(loan.findExistingTransactionIds()).thenReturn(existingTransactionIds);
when(loanTransactionRepository.findTransactionIdsByLoan(loan)).thenReturn(existingTransactionIds);
when(loan.findExistingReversedTransactionIds()).thenReturn(existingReversedTransactionIds);
when(loan.getLoanCharges()).thenReturn(new HashSet<>());