|
18 | 18 | */ |
19 | 19 | package org.apache.fineract.integrationtests; |
20 | 20 |
|
| 21 | +import static org.apache.fineract.integrationtests.common.BusinessDateHelper.runAt; |
21 | 22 | import static org.junit.jupiter.api.Assertions.assertEquals; |
22 | 23 |
|
23 | 24 | import io.restassured.builder.RequestSpecBuilder; |
|
55 | 56 | import org.apache.fineract.integrationtests.guarantor.GuarantorTestBuilder; |
56 | 57 | import org.junit.jupiter.api.Assertions; |
57 | 58 | import org.junit.jupiter.api.BeforeEach; |
58 | | -import org.junit.jupiter.api.Disabled; |
59 | 59 | import org.junit.jupiter.api.Test; |
60 | 60 | import org.junit.jupiter.api.extension.ExtendWith; |
61 | 61 | import org.slf4j.Logger; |
@@ -903,7 +903,6 @@ private Map<String, Object> savingsArray(final Long paymentId, final Integer sav |
903 | 903 | * </ul> |
904 | 904 | */ |
905 | 905 | @Test |
906 | | - @Disabled("Using GROUP as Client guarantor causes issues... need to be fixed to support GROUP as guarantor") |
907 | 906 | public void testOnHoldTransactionsApiForGroupSavingsAccount() { |
908 | 907 | this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); |
909 | 908 |
|
@@ -1076,52 +1075,57 @@ public void testGroupGuarantorWithInvalidGroupId() { |
1076 | 1075 | */ |
1077 | 1076 | @Test |
1078 | 1077 | public void testGroupGuarantorWithClientIdButGroupType() { |
1079 | | - this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); |
1080 | | - |
1081 | | - // Create TWO clients - one for loan, one to misuse as "group" |
1082 | | - final Integer loanClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); |
1083 | | - Assertions.assertNotNull(loanClientID); |
1084 | | - |
1085 | | - final Integer otherClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); |
1086 | | - Assertions.assertNotNull(otherClientID); |
1087 | | - |
1088 | | - // Create savings account for the other client |
1089 | | - final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, null, null, |
1090 | | - "false"); |
1091 | | - final Integer clientSavingsId = this.savingsAccountHelper.applyForSavingsApplication(otherClientID, savingsProductID, "INDIVIDUAL"); |
1092 | | - this.savingsAccountHelper.approveSavings(clientSavingsId); |
1093 | | - this.savingsAccountHelper.activateSavings(clientSavingsId); |
1094 | | - |
1095 | | - // Create loan product |
1096 | | - LoanProductTestBuilder loanProductBuilder = new LoanProductTestBuilder().withPrincipal(PRINCIPAL).withNumberOfRepayments("4") |
1097 | | - .withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2") |
1098 | | - .withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment().withInterestTypeAsDecliningBalance() |
1099 | | - .withOnHoldFundDetails("0", "0", "0"); |
1100 | | - final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductBuilder.build(null)); |
1101 | | - |
1102 | | - // Create loan |
1103 | | - final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(PRINCIPAL).withLoanTermFrequency("4") |
1104 | | - .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("4").withRepaymentEveryAfter("1").withRepaymentFrequencyTypeAsWeeks() |
1105 | | - .withInterestRatePerPeriod("2").withAmortizationTypeAsEqualInstallments().withInterestTypeAsDecliningBalance() |
1106 | | - .withInterestCalculationPeriodTypeSameAsRepaymentPeriod().withSubmittedOnDate(SavingsAccountHelper.TRANSACTION_DATE) |
1107 | | - .withExpectedDisbursementDate(SavingsAccountHelper.TRANSACTION_DATE) |
1108 | | - .build(loanClientID.toString(), loanProductID.toString(), null); |
1109 | | - final Integer loanID = this.loanTransactionHelper.getLoanId(loanApplicationJSON); |
1110 | | - |
1111 | | - // Try to create guarantor with CLIENT ID but GROUP type (type mismatch) |
1112 | | - String guarantorJSON = new GuarantorTestBuilder() |
1113 | | - .existingGroupWithGuaranteeAmount(String.valueOf(otherClientID), String.valueOf(clientSavingsId), GUARANTEE_AMOUNT).build(); |
1114 | | - |
1115 | | - final ResponseSpecification errorResponse = new ResponseSpecBuilder().build(); |
1116 | | - final RequestSpecification errorRequest = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); |
1117 | | - errorRequest.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); |
1118 | | - |
1119 | | - ArrayList<HashMap> error = (ArrayList<HashMap>) this.guarantorHelper.createGuarantorWithError(loanID, guarantorJSON, errorRequest, |
1120 | | - errorResponse); |
1121 | | - // Verify we got an error response (status code may be 403 or 404 depending on environment) |
1122 | | - Assertions.assertNotNull(error, "Should return error for client ID used with GROUP type"); |
1123 | | - |
1124 | | - LOG.info("SUCCESS: Client ID with GROUP type correctly rejected"); |
| 1078 | + runAt("01 January 2023", () -> { |
| 1079 | + this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec); |
| 1080 | + |
| 1081 | + // Create TWO clients - one for loan, one to misuse as "group" |
| 1082 | + final Integer loanClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); |
| 1083 | + Assertions.assertNotNull(loanClientID); |
| 1084 | + |
| 1085 | + final Integer otherClientID = ClientHelper.createClient(this.requestSpec, this.responseSpec); |
| 1086 | + Assertions.assertNotNull(otherClientID); |
| 1087 | + |
| 1088 | + // Create savings account for the other client |
| 1089 | + final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, null, null, |
| 1090 | + "false"); |
| 1091 | + final Integer clientSavingsId = this.savingsAccountHelper.applyForSavingsApplication(otherClientID, savingsProductID, |
| 1092 | + "INDIVIDUAL"); |
| 1093 | + this.savingsAccountHelper.approveSavings(clientSavingsId); |
| 1094 | + this.savingsAccountHelper.activateSavings(clientSavingsId); |
| 1095 | + |
| 1096 | + // Create loan product |
| 1097 | + LoanProductTestBuilder loanProductBuilder = new LoanProductTestBuilder().withPrincipal(PRINCIPAL).withNumberOfRepayments("4") |
| 1098 | + .withRepaymentAfterEvery("1").withRepaymentTypeAsWeek().withinterestRatePerPeriod("2") |
| 1099 | + .withInterestRateFrequencyTypeAsMonths().withAmortizationTypeAsEqualPrincipalPayment() |
| 1100 | + .withInterestTypeAsDecliningBalance().withOnHoldFundDetails("0", "0", "0"); |
| 1101 | + final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(loanProductBuilder.build(null)); |
| 1102 | + |
| 1103 | + // Create loan |
| 1104 | + final String loanApplicationJSON = new LoanApplicationTestBuilder().withPrincipal(PRINCIPAL).withLoanTermFrequency("4") |
| 1105 | + .withLoanTermFrequencyAsWeeks().withNumberOfRepayments("4").withRepaymentEveryAfter("1") |
| 1106 | + .withRepaymentFrequencyTypeAsWeeks().withInterestRatePerPeriod("2").withAmortizationTypeAsEqualInstallments() |
| 1107 | + .withInterestTypeAsDecliningBalance().withInterestCalculationPeriodTypeSameAsRepaymentPeriod() |
| 1108 | + .withSubmittedOnDate(SavingsAccountHelper.TRANSACTION_DATE) |
| 1109 | + .withExpectedDisbursementDate(SavingsAccountHelper.TRANSACTION_DATE) |
| 1110 | + .build(loanClientID.toString(), loanProductID.toString(), null); |
| 1111 | + final Integer loanID = this.loanTransactionHelper.getLoanId(loanApplicationJSON); |
| 1112 | + |
| 1113 | + // Try to create guarantor with CLIENT ID but GROUP type (type mismatch) |
| 1114 | + String guarantorJSON = new GuarantorTestBuilder() |
| 1115 | + .existingGroupWithGuaranteeAmount(String.valueOf(otherClientID), String.valueOf(clientSavingsId), GUARANTEE_AMOUNT) |
| 1116 | + .build(); |
| 1117 | + |
| 1118 | + final ResponseSpecification errorResponse = new ResponseSpecBuilder().build(); |
| 1119 | + final RequestSpecification errorRequest = new RequestSpecBuilder().setContentType(ContentType.JSON).build(); |
| 1120 | + errorRequest.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey()); |
| 1121 | + |
| 1122 | + ArrayList<HashMap> error = (ArrayList<HashMap>) this.guarantorHelper.createGuarantorWithError(loanID, guarantorJSON, |
| 1123 | + errorRequest, errorResponse); |
| 1124 | + // Verify we got an error response (status code may be 403 or 404 depending on environment) |
| 1125 | + Assertions.assertNotNull(error, "Should return error for client ID used with GROUP type"); |
| 1126 | + |
| 1127 | + LOG.info("SUCCESS: Client ID with GROUP type correctly rejected"); |
| 1128 | + }); |
1125 | 1129 | } |
1126 | 1130 |
|
1127 | 1131 | /** |
|
0 commit comments