[FINERACT-1678] LoanCOBFilterHelper call service instead of repository
This commit is contained in:
+5
@@ -67,6 +67,11 @@ public class RetrieveAllNonClosedLoanIdServiceImpl implements RetrieveLoanIdServ
|
||||
return new LoanCOBPartition(rs.getLong("min"), rs.getLong("max"), rs.getLong("page"), rs.getLong("count"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoanIdAndLastClosedBusinessDate> retrieveLoanIdsBehindDate(LocalDate businessDate, List<Long> loanIds) {
|
||||
return loanRepository.findAllNonClosedLoansBehindByLoanIds(businessDate, loanIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LoanIdAndLastClosedBusinessDate> retrieveLoanIdsBehindDateOrNull(LocalDate businessDate, List<Long> loanIds) {
|
||||
return loanRepository.findAllNonClosedLoansBehindOrNullByLoanIds(businessDate, loanIds);
|
||||
|
||||
+2
@@ -30,6 +30,8 @@ public interface RetrieveLoanIdService {
|
||||
|
||||
List<LoanCOBPartition> retrieveLoanCOBPartitions(Long numberOfDays, LocalDate businessDate, boolean isCatchUp, int partitionSize);
|
||||
|
||||
List<LoanIdAndLastClosedBusinessDate> retrieveLoanIdsBehindDate(LocalDate businessDate, List<Long> loanIds);
|
||||
|
||||
List<LoanIdAndLastClosedBusinessDate> retrieveLoanIdsBehindDateOrNull(LocalDate businessDate, List<Long> loanIds);
|
||||
|
||||
List<LoanIdAndLastClosedBusinessDate> retrieveLoanIdsOldestCobProcessed(LocalDate businessDate);
|
||||
|
||||
+4
-2
@@ -29,6 +29,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.cob.data.LoanIdAndLastClosedBusinessDate;
|
||||
import org.apache.fineract.cob.loan.RetrieveLoanIdService;
|
||||
import org.apache.fineract.cob.service.InlineLoanCOBExecutorServiceImpl;
|
||||
import org.apache.fineract.cob.service.LoanAccountLockService;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
@@ -55,6 +56,7 @@ public class LoanCOBFilterHelper {
|
||||
private final InlineLoanCOBExecutorServiceImpl inlineLoanCOBExecutorService;
|
||||
private final LoanRepository loanRepository;
|
||||
private final FineractProperties fineractProperties;
|
||||
private final RetrieveLoanIdService retrieveLoanIdService;
|
||||
|
||||
private final LoanRescheduleRequestRepository loanRescheduleRequestRepository;
|
||||
|
||||
@@ -128,8 +130,8 @@ public class LoanCOBFilterHelper {
|
||||
public boolean isLoanBehind(List<Long> loanIds) {
|
||||
List<LoanIdAndLastClosedBusinessDate> loanIdAndLastClosedBusinessDates = new ArrayList<>();
|
||||
List<List<Long>> partitions = Lists.partition(loanIds, fineractProperties.getQuery().getInClauseParameterSizeLimit());
|
||||
partitions.forEach(partition -> loanIdAndLastClosedBusinessDates.addAll(loanRepository
|
||||
.findAllNonClosedLoansBehindByLoanIds(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE), partition)));
|
||||
partitions.forEach(partition -> loanIdAndLastClosedBusinessDates.addAll(retrieveLoanIdService
|
||||
.retrieveLoanIdsBehindDate(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE), partition)));
|
||||
return CollectionUtils.isNotEmpty(loanIdAndLastClosedBusinessDates);
|
||||
}
|
||||
|
||||
|
||||
+15
-18
@@ -41,6 +41,7 @@ import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.apache.fineract.cob.data.LoanIdAndLastClosedBusinessDate;
|
||||
import org.apache.fineract.cob.loan.RetrieveLoanIdService;
|
||||
import org.apache.fineract.cob.service.InlineLoanCOBExecutorServiceImpl;
|
||||
import org.apache.fineract.cob.service.LoanAccountLockService;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
@@ -91,6 +92,8 @@ class LoanCOBApiFilterTest {
|
||||
private FineractProperties.FineractQueryProperties fineractQueryProperties;
|
||||
@Mock
|
||||
private LoanRescheduleRequestRepository loanRescheduleRequestRepository;
|
||||
@Mock
|
||||
private RetrieveLoanIdService retrieveLoanIdService;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
@@ -157,9 +160,8 @@ class LoanCOBApiFilterTest {
|
||||
given(context.authenticatedUser()).willReturn(appUser);
|
||||
given(fineractProperties.getQuery()).willReturn(fineractQueryProperties);
|
||||
given(fineractQueryProperties.getInClauseParameterSizeLimit()).willReturn(65000);
|
||||
given(loanRepository.findAllNonClosedLoansBehindOrNullByLoanIds(
|
||||
eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)), anyList()))
|
||||
.willReturn(Collections.emptyList());
|
||||
given(retrieveLoanIdService.retrieveLoanIdsBehindDate(eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)),
|
||||
anyList())).willReturn(Collections.emptyList());
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
verify(filterChain, times(1)).doFilter(request, response);
|
||||
@@ -200,9 +202,8 @@ class LoanCOBApiFilterTest {
|
||||
given(context.authenticatedUser()).willReturn(appUser);
|
||||
given(fineractProperties.getQuery()).willReturn(fineractQueryProperties);
|
||||
given(fineractQueryProperties.getInClauseParameterSizeLimit()).willReturn(65000);
|
||||
given(loanRepository.findAllNonClosedLoansBehindOrNullByLoanIds(
|
||||
eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)), anyList()))
|
||||
.willReturn(Collections.emptyList());
|
||||
given(retrieveLoanIdService.retrieveLoanIdsBehindDate(eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)),
|
||||
anyList())).willReturn(Collections.emptyList());
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
verify(filterChain, times(1)).doFilter(request, response);
|
||||
@@ -228,9 +229,8 @@ class LoanCOBApiFilterTest {
|
||||
given(loanRepository.findIdByExternalId(any())).willReturn(2L);
|
||||
given(fineractProperties.getQuery()).willReturn(fineractQueryProperties);
|
||||
given(fineractQueryProperties.getInClauseParameterSizeLimit()).willReturn(65000);
|
||||
given(loanRepository.findAllNonClosedLoansBehindOrNullByLoanIds(
|
||||
eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)), anyList()))
|
||||
.willReturn(Collections.emptyList());
|
||||
given(retrieveLoanIdService.retrieveLoanIdsBehindDate(eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)),
|
||||
anyList())).willReturn(Collections.emptyList());
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
verify(filterChain, times(1)).doFilter(request, response);
|
||||
@@ -258,9 +258,8 @@ class LoanCOBApiFilterTest {
|
||||
given(loanRescheduleRequestRepository.getLoanIdByRescheduleRequestId(resourceId)).willReturn(Optional.of(2L));
|
||||
given(context.authenticatedUser()).willReturn(appUser);
|
||||
|
||||
given(loanRepository.findAllNonClosedLoansBehindOrNullByLoanIds(
|
||||
eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)), anyList()))
|
||||
.willReturn(Collections.emptyList());
|
||||
given(retrieveLoanIdService.retrieveLoanIdsBehindDate(eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)),
|
||||
anyList())).willReturn(Collections.emptyList());
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
verify(filterChain, times(1)).doFilter(request, response);
|
||||
@@ -288,9 +287,8 @@ class LoanCOBApiFilterTest {
|
||||
given(loanAccountLockService.isLoanHardLocked(2L)).willReturn(false);
|
||||
given(fineractProperties.getQuery()).willReturn(fineractQueryProperties);
|
||||
given(fineractQueryProperties.getInClauseParameterSizeLimit()).willReturn(65000);
|
||||
given(loanRepository.findAllNonClosedLoansBehindByLoanIds(
|
||||
eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)), anyList()))
|
||||
.willReturn(Collections.singletonList(result));
|
||||
given(retrieveLoanIdService.retrieveLoanIdsBehindDate(eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)),
|
||||
anyList())).willReturn(Collections.singletonList(result));
|
||||
given(context.authenticatedUser()).willReturn(appUser);
|
||||
|
||||
testObj.doFilterInternal(request, response, filterChain);
|
||||
@@ -319,9 +317,8 @@ class LoanCOBApiFilterTest {
|
||||
given(loanAccountLockService.isLoanHardLocked(2L)).willReturn(false);
|
||||
given(fineractProperties.getQuery()).willReturn(fineractQueryProperties);
|
||||
given(fineractQueryProperties.getInClauseParameterSizeLimit()).willReturn(65000);
|
||||
given(loanRepository.findAllNonClosedLoansBehindOrNullByLoanIds(
|
||||
eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)), anyList()))
|
||||
.willReturn(Collections.emptyList());
|
||||
given(retrieveLoanIdService.retrieveLoanIdsBehindDate(eq(ThreadLocalContextUtil.getBusinessDateByType(BusinessDateType.COB_DATE)),
|
||||
anyList())).willReturn(Collections.emptyList());
|
||||
|
||||
given(context.authenticatedUser()).willReturn(appUser);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user