FINERACT-1971: Fix Delinquency bucket error upon Loan product editing

This commit is contained in:
Jose Alberto Hernandez
2024-01-29 09:23:42 +01:00
committed by Adam Saghy
parent f7a056204c
commit 1f00bb6d33
5 changed files with 29 additions and 8 deletions
@@ -285,12 +285,20 @@ public class DelinquencyBucketsIntegrationTest {
// Loan product creation without Delinquency bucket
GetLoanProductsProductIdResponse getLoanProductResponse = createLoanProduct(loanTransactionHelper, null, null);
assertNotNull(getLoanProductResponse);
assertNull(getLoanProductResponse.getDelinquencyBucket().getId());
// Loan product creation with Delinquency bucket
getLoanProductResponse = createLoanProduct(loanTransactionHelper, Math.toIntExact(delinquencyBucket.getId()), null);
assertNotNull(getLoanProductResponse);
log.info("Loan Product Bucket Name: {}", getLoanProductResponse.getDelinquencyBucket().getName());
assertEquals(getLoanProductResponse.getDelinquencyBucket().getName(), delinquencyBucket.getName());
// Update Loan product to remove the Delinquency bucket
final Long loanProductId = getLoanProductResponse.getId();
loanTransactionHelper.updateLoanProduct(loanProductId, "{delinquencyBucketId: null}");
getLoanProductResponse = loanTransactionHelper.getLoanProduct(loanProductId.intValue());
assertNotNull(getLoanProductResponse);
assertNull(getLoanProductResponse.getDelinquencyBucket().getId());
}
@Test
@@ -100,6 +100,7 @@ import org.apache.poi.ss.usermodel.Workbook;
public class LoanTransactionHelper extends IntegrationTest {
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
private static final String LOAN_PRODUCTS_URL = "/fineract-provider/api/v1/loanproducts";
private static final String CREATE_LOAN_PRODUCT_URL = "/fineract-provider/api/v1/loanproducts?" + Utils.TENANT_IDENTIFIER;
private static final String APPLY_LOAN_URL = "/fineract-provider/api/v1/loans?" + Utils.TENANT_IDENTIFIER;
private static final String LOAN_ACCOUNT_URL = "/fineract-provider/api/v1/loans";
@@ -1975,4 +1976,10 @@ public class LoanTransactionHelper extends IntegrationTest {
final String ADD_CHARGES_URL = LOAN_ACCOUNT_URL + "/" + loanId + "/charges?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPost(requestSpec, responseSpec, ADD_CHARGES_URL, request, jsonAttributeToGetBack);
}
public Object updateLoanProduct(final Long loanProductId, final String request) {
final String UPDATE_LOAN_PRODUCT_URL = LOAN_PRODUCTS_URL + "/" + loanProductId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerPut(requestSpec, responseSpec, UPDATE_LOAN_PRODUCT_URL, request, null);
}
}