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