FINERACT-1724: Delinquency classification tests were failing
This commit is contained in:
committed by
Adam Saghy
parent
367550007c
commit
18811e57b3
+35
-26
@@ -34,6 +34,7 @@ import java.time.LocalDate;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.fineract.client.models.BusinessDateResponse;
|
||||||
import org.apache.fineract.client.models.DeleteDelinquencyBucketResponse;
|
import org.apache.fineract.client.models.DeleteDelinquencyBucketResponse;
|
||||||
import org.apache.fineract.client.models.DeleteDelinquencyRangeResponse;
|
import org.apache.fineract.client.models.DeleteDelinquencyRangeResponse;
|
||||||
import org.apache.fineract.client.models.GetDelinquencyBucketsResponse;
|
import org.apache.fineract.client.models.GetDelinquencyBucketsResponse;
|
||||||
@@ -64,7 +65,6 @@ import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
|
|||||||
import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper;
|
import org.apache.fineract.integrationtests.common.products.DelinquencyBucketsHelper;
|
||||||
import org.apache.fineract.integrationtests.common.products.DelinquencyRangesHelper;
|
import org.apache.fineract.integrationtests.common.products.DelinquencyRangesHelper;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -72,6 +72,7 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
|
|
||||||
private ResponseSpecification responseSpec;
|
private ResponseSpecification responseSpec;
|
||||||
private RequestSpecification requestSpec;
|
private RequestSpecification requestSpec;
|
||||||
|
private BusinessDateHelper businessDateHelper;
|
||||||
private static final String principalAmount = "10000";
|
private static final String principalAmount = "10000";
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
@@ -81,6 +82,7 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
|
this.businessDateHelper = new BusinessDateHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -236,10 +238,16 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Disabled("It was failing at the beginning of some moths")
|
|
||||||
public void testLoanClassificationRealtime() {
|
public void testLoanClassificationRealtime() {
|
||||||
// Given
|
// Given
|
||||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||||
|
|
||||||
|
final LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 March 2012");
|
||||||
|
log.info("Current date {}", bussinesLocalDate);
|
||||||
|
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||||
|
final BusinessDateResponse businessDateResponse = this.businessDateHelper.getBusinessDateByType(requestSpec, responseSpec,
|
||||||
|
BusinessDateType.BUSINESS_DATE);
|
||||||
|
|
||||||
ArrayList<Integer> rangeIds = new ArrayList<>();
|
ArrayList<Integer> rangeIds = new ArrayList<>();
|
||||||
// First Range
|
// First Range
|
||||||
@@ -275,9 +283,8 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
log.info("Loan Product Bucket Name: {}", getLoanProductsProductResponse.getDelinquencyBucket().getName());
|
log.info("Loan Product Bucket Name: {}", getLoanProductsProductResponse.getDelinquencyBucket().getName());
|
||||||
assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
|
assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
|
||||||
|
|
||||||
final LocalDate todaysDate = Utils.getLocalDateOfTenant();
|
|
||||||
// Older date to have more than one overdue installment
|
// Older date to have more than one overdue installment
|
||||||
final LocalDate transactionDate = todaysDate.minusDays(50);
|
final LocalDate transactionDate = bussinesLocalDate.minusDays(50);
|
||||||
String operationDate = Utils.dateFormatter.format(transactionDate);
|
String operationDate = Utils.dateFormatter.format(transactionDate);
|
||||||
|
|
||||||
// Create Loan Account
|
// Create Loan Account
|
||||||
@@ -285,15 +292,16 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
getLoanProductsProductResponse.getId().toString(), operationDate);
|
getLoanProductsProductResponse.getId().toString(), operationDate);
|
||||||
|
|
||||||
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
GetLoansLoanIdResponse getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
log.info("Loan Delinquency Range after Disbursement {}", getLoansLoanIdResponse.getDelinquencyRange().getClassification());
|
|
||||||
assertNotNull(getLoansLoanIdResponse);
|
assertNotNull(getLoansLoanIdResponse);
|
||||||
|
assertNotNull(getLoansLoanIdResponse.getDelinquencyRange());
|
||||||
|
log.info("Loan Delinquency Range after Disbursement {}", getLoansLoanIdResponse.getDelinquencyRange().getClassification());
|
||||||
// First Loan Delinquency Classification after Disbursement command
|
// First Loan Delinquency Classification after Disbursement command
|
||||||
assertEquals(getLoansLoanIdResponse.getDelinquencyRange().getClassification(), classificationExpected);
|
assertEquals(getLoansLoanIdResponse.getDelinquencyRange().getClassification(), classificationExpected);
|
||||||
|
|
||||||
loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse);
|
loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse);
|
||||||
|
|
||||||
// Apply a partial repayment
|
// Apply a partial repayment
|
||||||
operationDate = Utils.dateFormatter.format(todaysDate);
|
operationDate = Utils.dateFormatter.format(bussinesLocalDate);
|
||||||
loanTransactionHelper.makeLoanRepayment(operationDate, 100.0f, loanId);
|
loanTransactionHelper.makeLoanRepayment(operationDate, 100.0f, loanId);
|
||||||
|
|
||||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
@@ -316,16 +324,20 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
log.info("Delinquency Tag History items {}", getDelinquencyTagsHistory.size());
|
log.info("Delinquency Tag History items {}", getDelinquencyTagsHistory.size());
|
||||||
assertEquals(1, getDelinquencyTagsHistory.size());
|
assertEquals(1, getDelinquencyTagsHistory.size());
|
||||||
assertNotNull(getDelinquencyTagsHistory.get(0).getLiftedOnDate());
|
assertNotNull(getDelinquencyTagsHistory.get(0).getLiftedOnDate());
|
||||||
assertEquals(getDelinquencyTagsHistory.get(0).getAddedOnDate(), Utils.getLocalDateOfTenant());
|
assertEquals(getDelinquencyTagsHistory.get(0).getAddedOnDate(), businessDateResponse.getDate());
|
||||||
assertEquals(getDelinquencyTagsHistory.get(0).getLiftedOnDate(), Utils.getLocalDateOfTenant());
|
assertEquals(getDelinquencyTagsHistory.get(0).getLiftedOnDate(), businessDateResponse.getDate());
|
||||||
assertEquals(getDelinquencyTagsHistory.get(0).getDelinquencyRange().getClassification(), classificationExpected);
|
assertEquals(getDelinquencyTagsHistory.get(0).getDelinquencyRange().getClassification(), classificationExpected);
|
||||||
log.info("Delinquency Tag Item with Lifted On {}", getDelinquencyTagsHistory.get(0).getLiftedOnDate());
|
log.info("Delinquency Tag Item with Lifted On {}", getDelinquencyTagsHistory.get(0).getLiftedOnDate());
|
||||||
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Disabled("It was failing at the beginning of some moths")
|
|
||||||
public void testLoanClassificationRealtimeWithCharges() {
|
public void testLoanClassificationRealtimeWithCharges() {
|
||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||||
|
|
||||||
|
final LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 April 2012");
|
||||||
|
log.info("Current date {}", bussinesLocalDate);
|
||||||
|
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||||
|
|
||||||
// Given
|
// Given
|
||||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
@@ -364,9 +376,8 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
log.info("Loan Product Bucket Name: {}", getLoanProductsProductResponse.getDelinquencyBucket().getName());
|
log.info("Loan Product Bucket Name: {}", getLoanProductsProductResponse.getDelinquencyBucket().getName());
|
||||||
assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
|
assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
|
||||||
|
|
||||||
final LocalDate todaysDate = Utils.getLocalDateOfTenant();
|
|
||||||
// Older date to have more than one overdue installment
|
// Older date to have more than one overdue installment
|
||||||
LocalDate transactionDate = todaysDate.minusMonths(2).minusDays(5);
|
LocalDate transactionDate = bussinesLocalDate.minusMonths(2).minusDays(5);
|
||||||
String operationDate = Utils.dateFormatter.format(transactionDate);
|
String operationDate = Utils.dateFormatter.format(transactionDate);
|
||||||
|
|
||||||
// Create Loan Account
|
// Create Loan Account
|
||||||
@@ -381,7 +392,7 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse);
|
loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse);
|
||||||
|
|
||||||
// Apply a repayment to get a full paid installment
|
// Apply a repayment to get a full paid installment
|
||||||
operationDate = Utils.dateFormatter.format(todaysDate);
|
operationDate = Utils.dateFormatter.format(bussinesLocalDate);
|
||||||
loanTransactionHelper.makeLoanRepayment(operationDate, 2049.99f, loanId);
|
loanTransactionHelper.makeLoanRepayment(operationDate, 2049.99f, loanId);
|
||||||
|
|
||||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
@@ -391,7 +402,7 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
assertNull(getLoansLoanIdResponse.getDelinquencyRange());
|
assertNull(getLoansLoanIdResponse.getDelinquencyRange());
|
||||||
loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse);
|
loanTransactionHelper.printRepaymentSchedule(getLoansLoanIdResponse);
|
||||||
|
|
||||||
transactionDate = todaysDate.minusDays(18);
|
transactionDate = bussinesLocalDate.minusDays(18);
|
||||||
operationDate = Utils.dateFormatter.format(transactionDate);
|
operationDate = Utils.dateFormatter.format(transactionDate);
|
||||||
|
|
||||||
// Create and apply Charge for Specific Due Date
|
// Create and apply Charge for Specific Due Date
|
||||||
@@ -409,6 +420,7 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
assertNotNull(getLoansLoanIdResponse.getDelinquencyRange());
|
assertNotNull(getLoansLoanIdResponse.getDelinquencyRange());
|
||||||
// Evaluate a Delinquency Tag set after add charge to the Loan
|
// Evaluate a Delinquency Tag set after add charge to the Loan
|
||||||
assertEquals(getLoansLoanIdResponse.getDelinquencyRange().getClassification(), classificationExpected);
|
assertEquals(getLoansLoanIdResponse.getDelinquencyRange().getClassification(), classificationExpected);
|
||||||
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -706,15 +718,13 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("Failing test.Need rework")
|
|
||||||
@Test
|
@Test
|
||||||
public void testLoanClassificationStepAsPartOfCOB() {
|
public void testLoanClassificationStepAsPartOfCOB() {
|
||||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
GlobalConfigurationHelper.updateIsBusinessDateEnabled(requestSpec, responseSpec, Boolean.TRUE);
|
||||||
|
|
||||||
LocalDate businessDate = Utils.getLocalDateOfTenant();
|
LocalDate bussinesLocalDate = Utils.getDateAsLocalDate("01 April 2012");
|
||||||
businessDate = businessDate.minusDays(4);
|
log.info("Current date {}", bussinesLocalDate);
|
||||||
log.info("Current date {}", businessDate);
|
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate);
|
|
||||||
|
|
||||||
// Given
|
// Given
|
||||||
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
final LoanTransactionHelper loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
|
||||||
@@ -748,9 +758,8 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
log.info("Loan Product Bucket Name: {}", getLoanProductsProductResponse.getDelinquencyBucket().getName());
|
log.info("Loan Product Bucket Name: {}", getLoanProductsProductResponse.getDelinquencyBucket().getName());
|
||||||
assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
|
assertEquals(getLoanProductsProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
|
||||||
|
|
||||||
final LocalDate todaysDate = Utils.getLocalDateOfTenant();
|
|
||||||
// Older date to have more than one overdue installment
|
// Older date to have more than one overdue installment
|
||||||
final LocalDate transactionDate = todaysDate.minusDays(33);
|
final LocalDate transactionDate = bussinesLocalDate.minusDays(31);
|
||||||
String operationDate = Utils.dateFormatter.format(transactionDate);
|
String operationDate = Utils.dateFormatter.format(transactionDate);
|
||||||
|
|
||||||
// Create Loan Account
|
// Create Loan Account
|
||||||
@@ -784,11 +793,11 @@ public class DelinquencyBucketsIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Move the Business date to get older the loan and to have an overdue loan
|
// Move the Business date to get older the loan and to have an overdue loan
|
||||||
LocalDate lastLoanCOBBusinessDate = businessDate;
|
LocalDate lastLoanCOBBusinessDate = bussinesLocalDate;
|
||||||
businessDate = businessDate.plusDays(3);
|
bussinesLocalDate = bussinesLocalDate.plusDays(3);
|
||||||
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, businessDate, jobName, responseSpec);
|
schedulerJobHelper.fastForwardTime(lastLoanCOBBusinessDate, bussinesLocalDate, jobName, responseSpec);
|
||||||
log.info("Current date {}", businessDate);
|
log.info("Current date {}", bussinesLocalDate);
|
||||||
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, businessDate);
|
BusinessDateHelper.updateBusinessDate(requestSpec, responseSpec, BusinessDateType.BUSINESS_DATE, bussinesLocalDate);
|
||||||
// Run Second time the Job
|
// Run Second time the Job
|
||||||
schedulerJobHelper.executeAndAwaitJob(jobName);
|
schedulerJobHelper.executeAndAwaitJob(jobName);
|
||||||
|
|
||||||
|
|||||||
+11
@@ -27,12 +27,15 @@ import java.util.List;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.fineract.client.models.BusinessDateRequest;
|
import org.apache.fineract.client.models.BusinessDateRequest;
|
||||||
import org.apache.fineract.client.models.BusinessDateResponse;
|
import org.apache.fineract.client.models.BusinessDateResponse;
|
||||||
|
import org.apache.fineract.client.util.JSON;
|
||||||
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
|
||||||
import org.apache.fineract.integrationtests.client.IntegrationTest;
|
import org.apache.fineract.integrationtests.client.IntegrationTest;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class BusinessDateHelper extends IntegrationTest {
|
public final class BusinessDateHelper extends IntegrationTest {
|
||||||
|
|
||||||
|
private static final Gson GSON = new JSON().getGson();
|
||||||
|
|
||||||
public BusinessDateHelper() {}
|
public BusinessDateHelper() {}
|
||||||
|
|
||||||
public static HashMap updateBusinessDate(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static HashMap updateBusinessDate(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
@@ -49,6 +52,14 @@ public final class BusinessDateHelper extends IntegrationTest {
|
|||||||
return ok(fineract().businessDateManagement.updateBusinessDate(request));
|
return ok(fineract().businessDateManagement.updateBusinessDate(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BusinessDateResponse getBusinessDateByType(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
|
final BusinessDateType type) {
|
||||||
|
final String BUSINESS_DATE_API = "/fineract-provider/api/v1/businessdate/" + type.name() + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
|
final String response = Utils.performServerGet(requestSpec, responseSpec, BUSINESS_DATE_API);
|
||||||
|
log.info("{}", response);
|
||||||
|
return GSON.fromJson(response, BusinessDateResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
public BusinessDateResponse getBusinessDate(final String type) {
|
public BusinessDateResponse getBusinessDate(final String type) {
|
||||||
return ok(fineract().businessDateManagement.getBusinessDate(type));
|
return ok(fineract().businessDateManagement.getBusinessDate(type));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -461,4 +461,7 @@ public final class Utils {
|
|||||||
return new Gson().toJson(map);
|
return new Gson().toJson(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LocalDate getDateAsLocalDate(String dateAsString) {
|
||||||
|
return LocalDate.parse(dateAsString, dateFormatter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user