FINERACT-1971: Fixing long running COB related tests
This commit is contained in:
+1
@@ -22,4 +22,5 @@ FINERACT_MODE_BATCH_MANAGER_ENABLED=true
|
||||
FINERACT_MODE_BATCH_WORKER_ENABLED=false
|
||||
LOAN_COB_CHUNK_SIZE=10
|
||||
LOAN_COB_PARTITION_SIZE=10
|
||||
LOAN_COB_POLL_INTERVAL=1000
|
||||
OTEL_SERVICE_NAME=fineract-manager
|
||||
|
||||
+1
@@ -162,6 +162,7 @@ public class FineractProperties {
|
||||
private Integer threadPoolMaxPoolSize;
|
||||
private Integer threadPoolQueueCapacity;
|
||||
private Integer retryLimit;
|
||||
private Integer pollInterval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -18,9 +18,12 @@
|
||||
*/
|
||||
package org.apache.fineract.cob.api;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
@@ -28,6 +31,7 @@ import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,6 +44,8 @@ import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
|
||||
import org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -51,9 +57,14 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
public class InternalCOBApiResource implements InitializingBean {
|
||||
|
||||
private static final String DATETIME_PATTERN = "dd MMMM yyyy";
|
||||
|
||||
private final RetrieveLoanIdService retrieveLoanIdService;
|
||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||
private final ToApiJsonSerializer<List> toApiJsonSerializerForList;
|
||||
private final LoanRepositoryWrapper loanRepositoryWrapper;
|
||||
|
||||
protected DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATETIME_PATTERN);
|
||||
|
||||
@Override
|
||||
@SuppressFBWarnings("SLF4J_SIGN_ONLY_FORMAT")
|
||||
@@ -80,4 +91,16 @@ public class InternalCOBApiResource implements InitializingBean {
|
||||
return toApiJsonSerializerForList.serialize(settings, loanCOBPartitions);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Path("fast-forward-cob-date-of-loan/{loanId}")
|
||||
public void updateLoanCobLastDate(@Context final UriInfo uriInfo, @PathParam("loanId") long loanId, String jsonBody) {
|
||||
JsonElement root = JsonParser.parseString(jsonBody);
|
||||
String lastClosedBusinessDate = root.getAsJsonObject().get("lastClosedBusinessDate").getAsString();
|
||||
Loan loan = loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);
|
||||
LocalDate localDate = LocalDate.parse(lastClosedBusinessDate, dateTimeFormatter);
|
||||
loan.setLastClosedBusinessDate(localDate);
|
||||
loanRepositoryWrapper.save(loan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
package org.apache.fineract.cob.loan;
|
||||
|
||||
import static org.apache.fineract.cob.loan.LoanCOBConstant.LOAN_COB_JOB_NAME;
|
||||
|
||||
import org.apache.fineract.cob.COBBusinessStepService;
|
||||
import org.apache.fineract.cob.common.CustomJobParameterResolver;
|
||||
import org.apache.fineract.cob.conditions.BatchManagerCondition;
|
||||
@@ -85,7 +87,8 @@ public class LoanCOBManagerConfiguration {
|
||||
@Bean
|
||||
public Step loanCOBStep() {
|
||||
return stepBuilderFactory.get(LoanCOBConstant.LOAN_COB_PARTITIONER_STEP)
|
||||
.partitioner(LoanCOBConstant.LOAN_COB_WORKER_STEP, partitioner()).outputChannel(outboundRequests).build();
|
||||
.partitioner(LoanCOBConstant.LOAN_COB_WORKER_STEP, partitioner())
|
||||
.pollInterval(propertyService.getPollInterval(LOAN_COB_JOB_NAME)).outputChannel(outboundRequests).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
+2
@@ -31,4 +31,6 @@ public interface PropertyService {
|
||||
Integer getThreadPoolMaxPoolSize(String jobName);
|
||||
|
||||
Integer getThreadPoolQueueCapacity(String jobName);
|
||||
|
||||
Integer getPollInterval(String jobName);
|
||||
}
|
||||
|
||||
+5
@@ -60,6 +60,11 @@ public class PropertyServiceImpl implements PropertyService {
|
||||
return getProperty(jobName, FineractProperties.PartitionedJobProperty::getThreadPoolQueueCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPollInterval(String jobName) {
|
||||
return getProperty(jobName, FineractProperties.PartitionedJobProperty::getPollInterval);
|
||||
}
|
||||
|
||||
private Integer getProperty(String jobName, Function<? super FineractProperties.PartitionedJobProperty, Integer> function) {
|
||||
List<FineractProperties.PartitionedJobProperty> jobProperties = fineractProperties.getPartitionedJob()
|
||||
.getPartitionedJobProperties();
|
||||
|
||||
@@ -69,6 +69,7 @@ fineract.partitioned-job.partitioned-job-properties[0].thread-pool-core-pool-siz
|
||||
fineract.partitioned-job.partitioned-job-properties[0].thread-pool-max-pool-size=${LOAN_COB_THREAD_POOL_MAX_POOL_SIZE:5}
|
||||
fineract.partitioned-job.partitioned-job-properties[0].thread-pool-queue-capacity=${LOAN_COB_THREAD_POOL_QUEUE_CAPACITY:20}
|
||||
fineract.partitioned-job.partitioned-job-properties[0].retry-limit=${LOAN_COB_RETRY_LIMIT:5}
|
||||
fineract.partitioned-job.partitioned-job-properties[0].poll-interval=${LOAN_COB_POLL_INTERVAL:10000}
|
||||
|
||||
fineract.remote-job-message-handler.spring-events.enabled=${FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED:true}
|
||||
fineract.remote-job-message-handler.jms.enabled=${FINERACT_REMOTE_JOB_MESSAGE_HANDLER_JMS_ENABLED:false}
|
||||
|
||||
@@ -46,6 +46,7 @@ fineract.partitioned-job.partitioned-job-properties[0].thread-pool-core-pool-siz
|
||||
fineract.partitioned-job.partitioned-job-properties[0].thread-pool-max-pool-size=1
|
||||
fineract.partitioned-job.partitioned-job-properties[0].thread-pool-queue-capacity=1
|
||||
fineract.partitioned-job.partitioned-job-properties[0].retry-limit=5
|
||||
fineract.partitioned-job.partitioned-job-properties[0].poll-interval=10000
|
||||
|
||||
fineract.remote-job-message-handler.spring-events.enabled=${FINERACT_REMOTE_JOB_MESSAGE_HANDLER_SPRING_EVENTS_ENABLED:true}
|
||||
fineract.remote-job-message-handler.jms.enabled=${FINERACT_REMOTE_JOB_MESSAGE_HANDLER_JMS_ENABLED:false}
|
||||
|
||||
+1
@@ -109,6 +109,7 @@ public abstract class BaseLoanIntegrationTest {
|
||||
protected static final String DATETIME_PATTERN = "dd MMMM yyyy";
|
||||
|
||||
protected final ResponseSpecification responseSpec = createResponseSpecification(Matchers.is(200));
|
||||
protected final ResponseSpecification responseSpec204 = createResponseSpecification(Matchers.is(204));
|
||||
|
||||
private final String fullAdminAuthKey = getFullAdminAuthKey();
|
||||
|
||||
|
||||
+122
-367
@@ -37,7 +37,9 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.fineract.client.models.BusinessDateResponse;
|
||||
import org.apache.fineract.client.models.DeleteDelinquencyBucketResponse;
|
||||
import org.apache.fineract.client.models.DeleteDelinquencyRangeResponse;
|
||||
@@ -68,6 +70,7 @@ import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
|
||||
import org.apache.fineract.integrationtests.common.SchedulerJobHelper;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.apache.fineract.integrationtests.common.charges.ChargesHelper;
|
||||
import org.apache.fineract.integrationtests.common.loans.CobHelper;
|
||||
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.apache.fineract.integrationtests.common.loans.LoanTestLifecycleExtension;
|
||||
@@ -80,7 +83,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
@Slf4j
|
||||
@ExtendWith(LoanTestLifecycleExtension.class)
|
||||
public class DelinquencyBucketsIntegrationTest {
|
||||
public class DelinquencyBucketsIntegrationTest extends BaseLoanIntegrationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
@@ -1062,39 +1065,17 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testDelinquencyWithPauseLettingPauseExpire() {
|
||||
try {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||
runAt("01 January 2012", () -> {
|
||||
|
||||
Integer delinquencyBucketId = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec, responseSpec, List.of(//
|
||||
Pair.of(1, 3), //
|
||||
Pair.of(4, 60) //
|
||||
));
|
||||
LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012");
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
|
||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||
|
||||
ArrayList<Integer> rangeIds = new ArrayList<>();
|
||||
String jsonRange = DelinquencyRangesHelper.getAsJSON(1, 3);
|
||||
PostDelinquencyRangeResponse delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec,
|
||||
responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
final GetDelinquencyRangesResponse range = DelinquencyRangesHelper.getDelinquencyRange(requestSpec, responseSpec,
|
||||
delinquencyRangeResponse.getResourceId());
|
||||
final String classificationExpected = range.getClassification();
|
||||
log.info("Expected Delinquency Range classification {}", classificationExpected);
|
||||
|
||||
jsonRange = DelinquencyRangesHelper.getAsJSON(4, 60);
|
||||
delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec, responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
|
||||
String jsonBucket = DelinquencyBucketsHelper.getAsJSON(rangeIds);
|
||||
PostDelinquencyBucketResponse delinquencyBucketResponse = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec,
|
||||
responseSpec, jsonBucket);
|
||||
final GetDelinquencyBucketsResponse delinquencyBucket = DelinquencyBucketsHelper.getDelinquencyBucket(requestSpec, responseSpec,
|
||||
delinquencyBucketResponse.getResourceId());
|
||||
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
|
||||
Math.toIntExact(delinquencyBucket.getId()), "3");
|
||||
delinquencyBucketId, "3");
|
||||
assertNotNull(getLoanProductsProductResponse);
|
||||
log.info("Loan Product Arrears: {}", getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
assertEquals(3, getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
@@ -1114,92 +1095,38 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
|
||||
final String jobName = "Loan COB";
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("06 February 2012");
|
||||
LocalDate lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "04 February 2012");
|
||||
updateBusinessDate("06 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
GetLoansLoanIdDelinquencySummary delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
PostLoansDelinquencyActionResponse pauseDelinquencyResponse = loanTransactionHelper
|
||||
.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "06 February 2012", "10 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("09 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "07 February 2012");
|
||||
updateBusinessDate("09 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("12 March 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "10 March 2012");
|
||||
updateBusinessDate("12 March 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(2049.99, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(36, delinquent.getDelinquentDays());
|
||||
} finally {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||
}
|
||||
verifyDelinquency(loanId, "01 February 2012", 2049.99, 36);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelinquencyWithPauseResumeBeforePauseExpires() {
|
||||
try {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||
|
||||
runAt("01 January 2012", () -> {
|
||||
Integer delinquencyBucketId = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec, responseSpec, List.of(//
|
||||
Pair.of(1, 3), //
|
||||
Pair.of(4, 60) //
|
||||
));
|
||||
LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012");
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
|
||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||
|
||||
ArrayList<Integer> rangeIds = new ArrayList<>();
|
||||
String jsonRange = DelinquencyRangesHelper.getAsJSON(1, 3);
|
||||
PostDelinquencyRangeResponse delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec,
|
||||
responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
final GetDelinquencyRangesResponse range = DelinquencyRangesHelper.getDelinquencyRange(requestSpec, responseSpec,
|
||||
delinquencyRangeResponse.getResourceId());
|
||||
final String classificationExpected = range.getClassification();
|
||||
log.info("Expected Delinquency Range classification {}", classificationExpected);
|
||||
|
||||
jsonRange = DelinquencyRangesHelper.getAsJSON(4, 60);
|
||||
delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec, responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
|
||||
String jsonBucket = DelinquencyBucketsHelper.getAsJSON(rangeIds);
|
||||
PostDelinquencyBucketResponse delinquencyBucketResponse = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec,
|
||||
responseSpec, jsonBucket);
|
||||
final GetDelinquencyBucketsResponse delinquencyBucket = DelinquencyBucketsHelper.getDelinquencyBucket(requestSpec, responseSpec,
|
||||
delinquencyBucketResponse.getResourceId());
|
||||
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
|
||||
Math.toIntExact(delinquencyBucket.getId()), "3");
|
||||
delinquencyBucketId, "3");
|
||||
assertNotNull(getLoanProductsProductResponse);
|
||||
log.info("Loan Product Arrears: {}", getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
assertEquals(3, getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
@@ -1219,105 +1146,48 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
|
||||
final String jobName = "Loan COB";
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("06 February 2012");
|
||||
LocalDate lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "04 February 2012");
|
||||
updateBusinessDate("06 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
GetLoansLoanIdDelinquencySummary delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
PostLoansDelinquencyActionResponse pauseDelinquencyResponse = loanTransactionHelper
|
||||
.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "06 February 2012", "10 March 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("09 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "07 February 2012");
|
||||
updateBusinessDate("09 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("10 February 2012");
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "10 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("12 March 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "10 March 2012");
|
||||
updateBusinessDate("12 March 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(2049.99, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(36, delinquent.getDelinquentDays());
|
||||
} finally {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||
}
|
||||
verifyDelinquency(loanId, "01 February 2012", 2049.99, 36);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelinquencyWithMultiplePausePeriods() {
|
||||
try {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||
runAt("01 January 2012", () -> {
|
||||
|
||||
LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012");
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
|
||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||
|
||||
ArrayList<Integer> rangeIds = new ArrayList<>();
|
||||
String jsonRange = DelinquencyRangesHelper.getAsJSON(1, 3);
|
||||
PostDelinquencyRangeResponse delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec,
|
||||
responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
final GetDelinquencyRangesResponse range = DelinquencyRangesHelper.getDelinquencyRange(requestSpec, responseSpec,
|
||||
delinquencyRangeResponse.getResourceId());
|
||||
final String classificationExpected = range.getClassification();
|
||||
log.info("Expected Delinquency Range classification {}", classificationExpected);
|
||||
|
||||
jsonRange = DelinquencyRangesHelper.getAsJSON(4, 60);
|
||||
delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec, responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
|
||||
String jsonBucket = DelinquencyBucketsHelper.getAsJSON(rangeIds);
|
||||
PostDelinquencyBucketResponse delinquencyBucketResponse = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec,
|
||||
responseSpec, jsonBucket);
|
||||
final GetDelinquencyBucketsResponse delinquencyBucket = DelinquencyBucketsHelper.getDelinquencyBucket(requestSpec, responseSpec,
|
||||
delinquencyBucketResponse.getResourceId());
|
||||
Integer delinquencyBucketId = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec, responseSpec, List.of(//
|
||||
Pair.of(1, 3), //
|
||||
Pair.of(4, 60) //
|
||||
));
|
||||
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProduct(loanTransactionHelper,
|
||||
Math.toIntExact(delinquencyBucket.getId()), "3");
|
||||
delinquencyBucketId, "3");
|
||||
assertNotNull(getLoanProductsProductResponse);
|
||||
log.info("Loan Product Arrears: {}", getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
assertEquals(3, getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
|
||||
final LocalDate transactionDate = bussinesLocalDate;
|
||||
String operationDate = Utils.dateFormatter.format(transactionDate);
|
||||
|
||||
final Integer loanId = createLoanAccount(loanTransactionHelper, clientId.toString(),
|
||||
getLoanProductsProductResponse.getId().toString(), operationDate, "3");
|
||||
getLoanProductsProductResponse.getId().toString(), "01 January 2012", "3");
|
||||
|
||||
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
final GetDelinquencyRangesResponse firstTestCase = getLoansLoanIdResponse.getDelinquencyRange();
|
||||
@@ -1328,146 +1198,78 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
|
||||
final String jobName = "Loan COB";
|
||||
|
||||
// delinqut days: 5
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("06 February 2012");
|
||||
LocalDate lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
// delinquent days: 5
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "04 February 2012");
|
||||
updateBusinessDate("06 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
GetLoansLoanIdDelinquencySummary delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
|
||||
// Add delinquency pause on 06 February 2012
|
||||
PostLoansDelinquencyActionResponse pauseDelinquencyResponse = loanTransactionHelper
|
||||
.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "06 February 2012", "10 March 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("09 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "07 February 2012");
|
||||
updateBusinessDate("09 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("10 February 2012");
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
// Add delinquency resume on 10 February 2012
|
||||
updateBusinessDate("10 February 2012");
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "10 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("13 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "11 February 2012");
|
||||
updateBusinessDate("13 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 8);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(8, delinquent.getDelinquentDays());
|
||||
|
||||
// Add new pause on 13 February 2012
|
||||
pauseDelinquencyResponse = loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "13 February 2012",
|
||||
"18 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("23 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "21 February 2012");
|
||||
updateBusinessDate("23 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 13);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(13, delinquent.getDelinquentDays());
|
||||
|
||||
// Add new pause on 23 February 2012
|
||||
pauseDelinquencyResponse = loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "23 February 2012",
|
||||
"28 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("25 February 2012");
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
updateBusinessDate("25 February 2012");
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "25 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("12 March 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "10 March 2012");
|
||||
updateBusinessDate("12 March 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 2049.99, 29);
|
||||
});
|
||||
}
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(2049.99, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(29, delinquent.getDelinquentDays());
|
||||
} finally {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||
}
|
||||
private void verifyDelinquency(Integer loanId, String date, Double amount, int delinquentDays) {
|
||||
GetLoansLoanIdResponse getLoansLoanIdResponse;
|
||||
GetLoansLoanIdDelinquencySummary delinquent;
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
assertEquals(amount, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.parse(date, dateTimeFormatter), delinquent.getDelinquentDate());
|
||||
assertEquals(delinquentDays, delinquent.getDelinquentDays());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelinquencyWithMultiplePausePeriodsWithInstallmentLevelDelinquency() {
|
||||
try {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||
|
||||
LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 January 2012");
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
|
||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||
final SchedulerJobHelper schedulerJobHelper = new SchedulerJobHelper(requestSpec);
|
||||
|
||||
ArrayList<Integer> rangeIds = new ArrayList<>();
|
||||
String jsonRange = DelinquencyRangesHelper.getAsJSON(1, 3);
|
||||
PostDelinquencyRangeResponse delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec,
|
||||
responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
final GetDelinquencyRangesResponse range = DelinquencyRangesHelper.getDelinquencyRange(requestSpec, responseSpec,
|
||||
delinquencyRangeResponse.getResourceId());
|
||||
final String classificationExpected = range.getClassification();
|
||||
log.info("Expected Delinquency Range classification {}", classificationExpected);
|
||||
|
||||
jsonRange = DelinquencyRangesHelper.getAsJSON(4, 60);
|
||||
delinquencyRangeResponse = DelinquencyRangesHelper.createDelinquencyRange(requestSpec, responseSpec, jsonRange);
|
||||
rangeIds.add(delinquencyRangeResponse.getResourceId());
|
||||
|
||||
String jsonBucket = DelinquencyBucketsHelper.getAsJSON(rangeIds);
|
||||
PostDelinquencyBucketResponse delinquencyBucketResponse = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec,
|
||||
responseSpec, jsonBucket);
|
||||
final GetDelinquencyBucketsResponse delinquencyBucket = DelinquencyBucketsHelper.getDelinquencyBucket(requestSpec, responseSpec,
|
||||
delinquencyBucketResponse.getResourceId());
|
||||
runAt("01 January 2012", () -> {
|
||||
Integer delinquencyBucketId = DelinquencyBucketsHelper.createDelinquencyBucket(requestSpec, responseSpec, List.of(//
|
||||
Pair.of(1, 3), //
|
||||
Pair.of(4, 60) //
|
||||
));
|
||||
|
||||
final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2012");
|
||||
final GetLoanProductsProductIdResponse getLoanProductsProductResponse = createLoanProductWithInstallmentLevelDelinquency(
|
||||
loanTransactionHelper, Math.toIntExact(delinquencyBucket.getId()), "3");
|
||||
loanTransactionHelper, delinquencyBucketId, "3");
|
||||
assertNotNull(getLoanProductsProductResponse);
|
||||
log.info("Loan Product Arrears: {}", getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
assertEquals(3, getLoanProductsProductResponse.getInArrearsTolerance());
|
||||
|
||||
final LocalDate transactionDate = bussinesLocalDate;
|
||||
String operationDate = Utils.dateFormatter.format(transactionDate);
|
||||
|
||||
final Integer loanId = createLoanAccount(loanTransactionHelper, clientId.toString(),
|
||||
getLoanProductsProductResponse.getId().toString(), operationDate, "3");
|
||||
getLoanProductsProductResponse.getId().toString(), "01 January 2012", "3");
|
||||
|
||||
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
final GetDelinquencyRangesResponse firstTestCase = getLoansLoanIdResponse.getDelinquencyRange();
|
||||
@@ -1478,94 +1280,49 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
|
||||
final String jobName = "Loan COB";
|
||||
|
||||
// delinqut days: 5
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("06 February 2012");
|
||||
LocalDate lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
// delinquent days: 5
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "04 February 2012");
|
||||
updateBusinessDate("06 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
PostLoansDelinquencyActionResponse pauseDelinquencyResponse = loanTransactionHelper
|
||||
.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "06 February 2012", "10 March 2012");
|
||||
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "07 February 2012");
|
||||
updateBusinessDate("09 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 5);
|
||||
|
||||
updateBusinessDate("10 February 2012");
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "10 February 2012");
|
||||
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "11 February 2012");
|
||||
updateBusinessDate("13 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 8);
|
||||
|
||||
pauseDelinquencyResponse = loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "13 February 2012",
|
||||
"18 February 2012");
|
||||
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "21 February 2012");
|
||||
updateBusinessDate("23 February 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
verifyDelinquency(loanId, "01 February 2012", 1033.33, 13);
|
||||
|
||||
pauseDelinquencyResponse = loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "23 February 2012",
|
||||
"28 February 2012");
|
||||
|
||||
updateBusinessDate("25 February 2012");
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "25 February 2012");
|
||||
|
||||
CobHelper.fastForwardLoansLastCOBDate(requestSpec, responseSpec204, loanId, "12 March 2012");
|
||||
updateBusinessDate("14 March 2012");
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
GetLoansLoanIdDelinquencySummary delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
|
||||
PostLoansDelinquencyActionResponse pauseDelinquencyResponse = loanTransactionHelper
|
||||
.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "06 February 2012", "10 March 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("09 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(5, delinquent.getDelinquentDays());
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("10 February 2012");
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "10 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("13 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(8, delinquent.getDelinquentDays());
|
||||
|
||||
pauseDelinquencyResponse = loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "13 February 2012",
|
||||
"18 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("23 February 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||
lastLoanCOBBusinessDate = bussinesLocalDate.minusDays(1);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(1033.33, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(13, delinquent.getDelinquentDays());
|
||||
|
||||
pauseDelinquencyResponse = loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), PAUSE, "23 February 2012",
|
||||
"28 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("25 February 2012");
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
loanTransactionHelper.createLoanDelinquencyAction(loanId.longValue(), RESUME, "25 February 2012");
|
||||
|
||||
bussinesLocalDate = Utils.getDateAsLocalDate("14 March 2012");
|
||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate.minusDays(1), jobName, responseSpec);
|
||||
log.info("Current date {}", bussinesLocalDate);
|
||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||
|
||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||
loanTransactionHelper.printDelinquencyData(getLoansLoanIdResponse);
|
||||
delinquent = getLoansLoanIdResponse.getDelinquent();
|
||||
|
||||
assertEquals(2049.99, delinquent.getDelinquentAmount());
|
||||
assertEquals(LocalDate.of(2012, 2, 1), delinquent.getDelinquentDate());
|
||||
assertEquals(31, delinquent.getDelinquentDays());
|
||||
@@ -1574,9 +1331,7 @@ public class DelinquencyBucketsIntegrationTest {
|
||||
assertEquals(BigDecimal.valueOf(1016.66), firstInstallmentDelinquent.getDelinquentAmount().stripTrailingZeros());
|
||||
GetLoansLoanIdLoanInstallmentLevelDelinquency secondInstallmentDelinquent = delinquent.getInstallmentLevelDelinquency().get(1);
|
||||
assertEquals(BigDecimal.valueOf(1033.33), secondInstallmentDelinquent.getDelinquentAmount().stripTrailingZeros());
|
||||
} finally {
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+10
@@ -220,6 +220,16 @@ public final class Utils {
|
||||
return (T) JsonPath.from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static <T> T performServerPatch(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL, final String jsonAttributeToGetBack) {
|
||||
final String json = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().patch(getURL).andReturn()
|
||||
.asString();
|
||||
if (jsonAttributeToGetBack == null) {
|
||||
return (T) json;
|
||||
}
|
||||
return (T) JsonPath.from(json).get(jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public static List<String> performServerGetList(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String getURL, final String jsonAttributeToGetBack) {
|
||||
final JsonPath jsonPath = given().spec(requestSpec).expect().spec(responseSpec).log().ifError().when().get(getURL).jsonPath();
|
||||
|
||||
+8
@@ -36,4 +36,12 @@ public final class CobHelper {
|
||||
log.info("---------------------------------GET COB PARTITIONS---------------------------------------------");
|
||||
return Utils.performServerGet(requestSpec, responseSpec, url, jsonReturn);
|
||||
}
|
||||
|
||||
public static void fastForwardLoansLastCOBDate(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final Integer loanId, final String cobDate) {
|
||||
final String url = "/fineract-provider/api/v1/internal/cob/fast-forward-cob-date-of-loan/" + loanId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
log.info("-------------------- -----------FAST FORWARD LAST COB DATE OF LOAN ----------------------------------------");
|
||||
Utils.performServerPost(requestSpec, responseSpec, url, "{\"lastClosedBusinessDate\":\"" + cobDate + "\"}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1697,7 +1697,7 @@ public class LoanTransactionHelper extends IntegrationTest {
|
||||
public void printDelinquencyData(GetLoansLoanIdResponse getLoansLoanIdResponse) {
|
||||
GetLoansLoanIdDelinquencySummary getLoansLoanIdCollectionData = getLoansLoanIdResponse.getDelinquent();
|
||||
if (getLoansLoanIdCollectionData != null) {
|
||||
log.info("Loan Delinquency {}", getLoansLoanIdCollectionData.toString());
|
||||
log.info("Loan Delinquency {}", getLoansLoanIdCollectionData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user