FINERACT-1932: Fineract modularization - fineract-cob
This commit is contained in:
committed by
Arnold Gálovics
parent
e090da2a01
commit
7452ea2552
+2
-2
@@ -34,7 +34,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.apache.fineract.cob.common.CustomJobParameterResolver;
|
||||
import org.apache.fineract.cob.data.LoanCOBParameter;
|
||||
import org.apache.fineract.cob.data.COBParameter;
|
||||
import org.apache.fineract.cob.domain.LoanAccountLock;
|
||||
import org.apache.fineract.cob.domain.LockOwner;
|
||||
import org.apache.fineract.cob.exceptions.LoanLockCannotBeAppliedException;
|
||||
@@ -76,7 +76,7 @@ public class ApplyLoanLockTaskletStepDefinitions implements En {
|
||||
ThreadLocalContextUtil.setBusinessDates(businessDateMap);
|
||||
StepExecution stepExecution = new StepExecution("test", null);
|
||||
ExecutionContext executionContext = new ExecutionContext();
|
||||
LoanCOBParameter loanCOBParameter = new LoanCOBParameter(1L, 4L);
|
||||
COBParameter loanCOBParameter = new COBParameter(1L, 4L);
|
||||
executionContext.put(LoanCOBConstant.LOAN_COB_PARAMETER, loanCOBParameter);
|
||||
lenient().when(
|
||||
retrieveLoanIdService.retrieveAllNonClosedLoansByLastClosedBusinessDateAndMinAndMaxLoanId(loanCOBParameter, false))
|
||||
|
||||
+4
-4
@@ -28,8 +28,8 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.fineract.cob.COBBusinessStepService;
|
||||
import org.apache.fineract.cob.data.BusinessStepNameAndOrder;
|
||||
import org.apache.fineract.cob.data.LoanCOBParameter;
|
||||
import org.apache.fineract.cob.data.LoanCOBPartition;
|
||||
import org.apache.fineract.cob.data.COBParameter;
|
||||
import org.apache.fineract.cob.data.COBPartition;
|
||||
import org.apache.fineract.infrastructure.jobs.service.JobName;
|
||||
import org.apache.fineract.infrastructure.springbatch.PropertyService;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
@@ -68,7 +68,7 @@ class LoanCOBPartitionerTest {
|
||||
when(cobBusinessStepService.getCOBBusinessSteps(LoanCOBBusinessStep.class, LoanCOBConstant.LOAN_COB_JOB_NAME))
|
||||
.thenReturn(BUSINESS_STEP_SET);
|
||||
when(retrieveLoanIdService.retrieveLoanCOBPartitions(1L, BUSINESS_DATE, false, 5))
|
||||
.thenReturn(List.of(new LoanCOBPartition(1L,10L, 1L, 5L), new LoanCOBPartition(11L,20L, 2L, 4L)));
|
||||
.thenReturn(List.of(new COBPartition(1L,10L, 1L, 5L), new COBPartition(11L,20L, 2L, 4L)));
|
||||
LoanCOBPartitioner loanCOBPartitioner = new LoanCOBPartitioner(propertyService, cobBusinessStepService, retrieveLoanIdService, jobOperator, jobExplorer, 1L);
|
||||
loanCOBPartitioner.setBusinessDate(BUSINESS_DATE);
|
||||
loanCOBPartitioner.setIsCatchUp(false);
|
||||
@@ -128,7 +128,7 @@ class LoanCOBPartitionerTest {
|
||||
private void validatePartitions(Map<String, ExecutionContext> partitions, int index, long min, long max) {
|
||||
Assertions.assertEquals(BUSINESS_STEP_SET,
|
||||
partitions.get(LoanCOBPartitioner.PARTITION_PREFIX + index).get(LoanCOBConstant.BUSINESS_STEPS));
|
||||
Assertions.assertEquals(new LoanCOBParameter(min, max),
|
||||
Assertions.assertEquals(new COBParameter(min, max),
|
||||
partitions.get(LoanCOBPartitioner.PARTITION_PREFIX + index).get(LoanCOBConstant.LOAN_COB_PARAMETER));
|
||||
Assertions.assertEquals("partition_" + index, partitions.get(LoanCOBPartitioner.PARTITION_PREFIX + index).get("partition"));
|
||||
}
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.fineract.cob.common.CustomJobParameterResolver;
|
||||
import org.apache.fineract.cob.data.LoanCOBParameter;
|
||||
import org.apache.fineract.cob.data.COBParameter;
|
||||
import org.apache.fineract.cob.domain.LoanAccountLock;
|
||||
import org.apache.fineract.cob.domain.LockOwner;
|
||||
import org.apache.fineract.cob.exceptions.LoanReadException;
|
||||
@@ -82,7 +82,7 @@ public class LoanItemReaderStepDefinitions implements En {
|
||||
minLoanId = splitAccounts.get(0);
|
||||
maxLoanId = splitAccounts.get(splitAccounts.size() - 1);
|
||||
}
|
||||
LoanCOBParameter loanCOBParameter = new LoanCOBParameter(minLoanId, maxLoanId);
|
||||
COBParameter loanCOBParameter = new COBParameter(minLoanId, maxLoanId);
|
||||
stepExecutionContext.put(LoanCOBConstant.LOAN_COB_PARAMETER, loanCOBParameter);
|
||||
stepExecution.setExecutionContext(stepExecutionContext);
|
||||
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.IntStream;
|
||||
import org.apache.fineract.cob.common.CustomJobParameterResolver;
|
||||
import org.apache.fineract.cob.data.LoanCOBParameter;
|
||||
import org.apache.fineract.cob.data.COBParameter;
|
||||
import org.apache.fineract.cob.domain.LoanAccountLock;
|
||||
import org.apache.fineract.cob.domain.LockOwner;
|
||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||
@@ -86,7 +86,7 @@ class LoanItemReaderTest {
|
||||
LoanItemReader loanItemReader = new LoanItemReader(loanRepository, retrieveLoanIdService, customJobParameterResolver,
|
||||
loanLockingService);
|
||||
when(stepExecution.getExecutionContext()).thenReturn(executionContext);
|
||||
LoanCOBParameter loanCOBParameter = new LoanCOBParameter(1L, 5L);
|
||||
COBParameter loanCOBParameter = new COBParameter(1L, 5L);
|
||||
when(executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER)).thenReturn(loanCOBParameter);
|
||||
when(retrieveLoanIdService.retrieveAllNonClosedLoansByLastClosedBusinessDateAndMinAndMaxLoanId(loanCOBParameter, false))
|
||||
.thenReturn(new ArrayList<>(List.of(1L, 2L, 3L, 4L, 5L)));
|
||||
@@ -114,7 +114,7 @@ class LoanItemReaderTest {
|
||||
LoanItemReader loanItemReader = new LoanItemReader(loanRepository, retrieveLoanIdService, customJobParameterResolver,
|
||||
loanLockingService);
|
||||
when(stepExecution.getExecutionContext()).thenReturn(executionContext);
|
||||
LoanCOBParameter loanCOBParameter = new LoanCOBParameter(1L, 5L);
|
||||
COBParameter loanCOBParameter = new COBParameter(1L, 5L);
|
||||
when(executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER)).thenReturn(loanCOBParameter);
|
||||
when(retrieveLoanIdService.retrieveAllNonClosedLoansByLastClosedBusinessDateAndMinAndMaxLoanId(loanCOBParameter, false))
|
||||
.thenReturn(new ArrayList<>(List.of()));
|
||||
@@ -135,7 +135,7 @@ class LoanItemReaderTest {
|
||||
LoanItemReader loanItemReader = new LoanItemReader(loanRepository, retrieveLoanIdService, customJobParameterResolver,
|
||||
loanLockingService);
|
||||
when(stepExecution.getExecutionContext()).thenReturn(executionContext);
|
||||
LoanCOBParameter loanCOBParameter = new LoanCOBParameter(1L, 100L);
|
||||
COBParameter loanCOBParameter = new COBParameter(1L, 100L);
|
||||
when(executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER)).thenReturn(loanCOBParameter);
|
||||
when(retrieveLoanIdService.retrieveAllNonClosedLoansByLastClosedBusinessDateAndMinAndMaxLoanId(loanCOBParameter, false))
|
||||
.thenReturn(new ArrayList<>(IntStream.rangeClosed(1, 100).boxed().map(Long::valueOf).toList()));
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.times;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import org.apache.fineract.cob.data.LoanCOBPartition;
|
||||
import org.apache.fineract.cob.data.COBPartition;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -48,7 +48,7 @@ public class RetrieveAllNonClosedLoanIdServiceImplTest {
|
||||
@Captor
|
||||
private ArgumentCaptor<SqlParameterSource> paramsCaptor;
|
||||
@Captor
|
||||
private ArgumentCaptor<RowMapper<LoanCOBPartition>> rowMapper;
|
||||
private ArgumentCaptor<RowMapper<COBPartition>> rowMapper;
|
||||
|
||||
@Test
|
||||
public void testRetrieveLoanCOBPartitionsNoCatchup() {
|
||||
|
||||
+13
-13
@@ -34,8 +34,8 @@ import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.apache.fineract.cob.data.LoanIdAndLastClosedBusinessDate;
|
||||
import org.apache.fineract.cob.exceptions.LoanAccountLockCannotBeOverruledException;
|
||||
import org.apache.fineract.cob.data.COBIdAndLastClosedBusinessDate;
|
||||
import org.apache.fineract.cob.exceptions.AccountLockCannotBeOverruledException;
|
||||
import org.apache.fineract.cob.loan.RetrieveLoanIdService;
|
||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
@@ -82,7 +82,7 @@ class InlineLoanCOBExecutorServiceImplTest {
|
||||
@Test
|
||||
void shouldExceptionThrownIfLoanIsAlreadyLocked() {
|
||||
JsonCommand command = mock(JsonCommand.class);
|
||||
LoanIdAndLastClosedBusinessDate loan = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
ThreadLocalContextUtil.setTenant(new FineractPlatformTenant(1L, "default", "Default", "Asia/Kolkata", null));
|
||||
HashMap<BusinessDateType, LocalDate> businessDates = new HashMap<>();
|
||||
LocalDate businessDate = LocalDate.now(ZoneId.systemDefault());
|
||||
@@ -90,7 +90,7 @@ class InlineLoanCOBExecutorServiceImplTest {
|
||||
businessDates.put(BusinessDateType.COB_DATE, businessDate.minusDays(1));
|
||||
ThreadLocalContextUtil.setBusinessDates(businessDates);
|
||||
|
||||
when(transactionTemplate.execute(any())).thenThrow(new LoanAccountLockCannotBeOverruledException(""));
|
||||
when(transactionTemplate.execute(any())).thenThrow(new AccountLockCannotBeOverruledException(""));
|
||||
when(fineractProperties.getQuery()).thenReturn(fineractQueryProperties);
|
||||
when(fineractProperties.getApi()).thenReturn(fineractApiProperties);
|
||||
when(dataParser.parseExecution(any())).thenReturn(List.of(1L));
|
||||
@@ -98,15 +98,15 @@ class InlineLoanCOBExecutorServiceImplTest {
|
||||
when(fineractApiProperties.getBodyItemSizeLimit()).thenReturn(fineractBodyItemSizeLimitProperties);
|
||||
when(fineractBodyItemSizeLimitProperties.getInlineLoanCob()).thenReturn(1000);
|
||||
when(retrieveLoanIdService.retrieveLoanIdsBehindDateOrNull(any(), anyList())).thenReturn(List.of(loan));
|
||||
assertThrows(LoanAccountLockCannotBeOverruledException.class, () -> testObj.executeInlineJob(command, "INLINE_LOAN_COB"));
|
||||
assertThrows(AccountLockCannotBeOverruledException.class, () -> testObj.executeInlineJob(command, "INLINE_LOAN_COB"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldListBePartitioned() {
|
||||
JsonCommand command = mock(JsonCommand.class);
|
||||
LoanIdAndLastClosedBusinessDate loan1 = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
LoanIdAndLastClosedBusinessDate loan2 = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
LoanIdAndLastClosedBusinessDate loan3 = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan1 = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan2 = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan3 = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
ThreadLocalContextUtil.setTenant(new FineractPlatformTenant(1L, "default", "Default", "Asia/Kolkata", null));
|
||||
HashMap<BusinessDateType, LocalDate> businessDates = new HashMap<>();
|
||||
LocalDate businessDate = LocalDate.now(ZoneId.systemDefault());
|
||||
@@ -114,7 +114,7 @@ class InlineLoanCOBExecutorServiceImplTest {
|
||||
businessDates.put(BusinessDateType.COB_DATE, businessDate.minusDays(1));
|
||||
ThreadLocalContextUtil.setBusinessDates(businessDates);
|
||||
|
||||
when(transactionTemplate.execute(any())).thenThrow(new LoanAccountLockCannotBeOverruledException(""));
|
||||
when(transactionTemplate.execute(any())).thenThrow(new AccountLockCannotBeOverruledException(""));
|
||||
when(fineractProperties.getQuery()).thenReturn(fineractQueryProperties);
|
||||
when(fineractProperties.getApi()).thenReturn(fineractApiProperties);
|
||||
when(dataParser.parseExecution(any())).thenReturn(List.of(1L, 2L, 3L));
|
||||
@@ -122,16 +122,16 @@ class InlineLoanCOBExecutorServiceImplTest {
|
||||
when(fineractApiProperties.getBodyItemSizeLimit()).thenReturn(fineractBodyItemSizeLimitProperties);
|
||||
when(fineractBodyItemSizeLimitProperties.getInlineLoanCob()).thenReturn(1000);
|
||||
when(retrieveLoanIdService.retrieveLoanIdsBehindDateOrNull(any(), anyList())).thenReturn(List.of(loan1, loan2, loan3));
|
||||
assertThrows(LoanAccountLockCannotBeOverruledException.class, () -> testObj.executeInlineJob(command, "INLINE_LOAN_COB"));
|
||||
assertThrows(AccountLockCannotBeOverruledException.class, () -> testObj.executeInlineJob(command, "INLINE_LOAN_COB"));
|
||||
verify(retrieveLoanIdService, times(2)).retrieveLoanIdsBehindDateOrNull(any(), anyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldOldestCloseBusinessDateReturnWithCorrectDate()
|
||||
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
LoanIdAndLastClosedBusinessDate loan1 = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
LoanIdAndLastClosedBusinessDate loan2 = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
LoanIdAndLastClosedBusinessDate loan3 = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan1 = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan2 = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate loan3 = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
when(loan1.getLastClosedBusinessDate()).thenReturn(null);
|
||||
when(loan2.getLastClosedBusinessDate()).thenReturn(LocalDate.of(2023, 1, 10));
|
||||
when(loan3.getLastClosedBusinessDate()).thenReturn(LocalDate.of(2023, 1, 11));
|
||||
|
||||
+3
-3
@@ -48,7 +48,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.apache.fineract.cob.data.LoanIdAndLastClosedBusinessDate;
|
||||
import org.apache.fineract.cob.data.COBIdAndLastClosedBusinessDate;
|
||||
import org.apache.fineract.cob.loan.RetrieveLoanIdService;
|
||||
import org.apache.fineract.cob.service.InlineLoanCOBExecutorServiceImpl;
|
||||
import org.apache.fineract.cob.service.LoanAccountLockService;
|
||||
@@ -312,7 +312,7 @@ class LoanCOBApiFilterTest {
|
||||
businessDates.put(BusinessDateType.COB_DATE, businessDate.minusDays(1));
|
||||
ThreadLocalContextUtil.setBusinessDates(businessDates);
|
||||
|
||||
LoanIdAndLastClosedBusinessDate result = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate result = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
given(result.getId()).willReturn(2L);
|
||||
given(result.getLastClosedBusinessDate()).willReturn(businessDate.minusDays(2));
|
||||
given(request.getPathInfo()).willReturn("/v1/loans/2?command=approve");
|
||||
@@ -346,7 +346,7 @@ class LoanCOBApiFilterTest {
|
||||
businessDates.put(BusinessDateType.COB_DATE, businessDate.minusDays(1));
|
||||
ThreadLocalContextUtil.setBusinessDates(businessDates);
|
||||
|
||||
LoanIdAndLastClosedBusinessDate result = mock(LoanIdAndLastClosedBusinessDate.class);
|
||||
COBIdAndLastClosedBusinessDate result = mock(COBIdAndLastClosedBusinessDate.class);
|
||||
given(result.getId()).willReturn(2L);
|
||||
given(request.getPathInfo()).willReturn("/v1/loans/2?command=approve");
|
||||
given(request.getMethod()).willReturn(HTTPMethods.POST.value());
|
||||
|
||||
Reference in New Issue
Block a user