This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 948af9ab2 FINERACT-1724 swagger fix
948af9ab2 is described below
commit 948af9ab2bcb1746ee770d2e2475f69dd6920e56
Author: Peter Kovacs <[email protected]>
AuthorDate: Tue Jul 11 13:54:01 2023 +0200
FINERACT-1724 swagger fix
---
.../paymenttype/data/PaymentTypeData.java | 6 +-
.../api/PaymentTypeApiResourceSwagger.java | 10 +--
.../ClientSavingsIntegrationTest.java | 14 +++-
.../GroupSavingsIntegrationTest.java | 10 ++-
.../LoanPostChargeOffScenariosTest.java | 9 +-
.../PaymentTypeIntegrationTest.java | 35 ++++----
.../RepaymentWithPostDatedChecksTest.java | 14 +++-
.../importhandler/loan/LoanImportHandlerTest.java | 11 ++-
.../populator/loan/LoanWorkbookPopulatorTest.java | 9 +-
.../integrationtests/common/PaymentTypeDomain.java | 8 +-
.../integrationtests/common/PaymentTypeHelper.java | 97 ++++++++--------------
.../common/charges/ChargesHelper.java | 4 +-
.../common/loans/LoanTransactionHelper.java | 10 ++-
13 files changed, 124 insertions(+), 113 deletions(-)
diff --git
a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java
b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java
index b626469bb..be656fd51 100644
---
a/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java
+++
b/fineract-core/src/main/java/org/apache/fineract/portfolio/paymenttype/data/PaymentTypeData.java
@@ -36,12 +36,12 @@ public class PaymentTypeData implements Serializable {
private String name;
private String description;
private Boolean isCashPayment;
- private Long position;
+ private Integer position;
private String codeName;
private Boolean isSystemDefined;
public static PaymentTypeData instance(final Long id, final String name,
final String description, final Boolean isCashPayment,
- final Long position) {
+ final Integer position) {
String codeName = null;
Boolean isSystemDefined = false;
return new PaymentTypeData(id, name, description, isCashPayment,
position, codeName, isSystemDefined);
@@ -50,7 +50,7 @@ public class PaymentTypeData implements Serializable {
public static PaymentTypeData instance(final Long id, final String name) {
String description = null;
Boolean isCashPayment = null;
- Long position = null;
+ Integer position = null;
String codeName = null;
Boolean isSystemDefined = false;
return new PaymentTypeData(id, name, description, isCashPayment,
position, codeName, isSystemDefined);
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java
index a2d065944..522c70134 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java
@@ -33,7 +33,7 @@ public final class PaymentTypeApiResourceSwagger {
private GetPaymentTypesResponse() {}
@Schema(example = "24")
- public Integer id;
+ public Long id;
@Schema(example = "PTC")
public String name;
@Schema(example = "Cash")
@@ -54,7 +54,7 @@ public final class PaymentTypeApiResourceSwagger {
private GetPaymentTypesPaymentTypeIdResponse() {}
@Schema(example = "13")
- public Integer id;
+ public Long id;
@Schema(example = "cash")
public String name;
@Schema(example = "cash Payment")
@@ -94,7 +94,7 @@ public final class PaymentTypeApiResourceSwagger {
private PostPaymentTypesResponse() {}
@Schema(example = "1")
- public Integer resourceId;
+ public Long resourceId;
}
@Schema(description = "PutPaymentTypesPaymentTypeIdRequest")
@@ -122,7 +122,7 @@ public final class PaymentTypeApiResourceSwagger {
private PutPaymentTypesPaymentTypeIdResponse() {}
@Schema(example = "13")
- public Integer resourceId;
+ public Long resourceId;
}
@Schema(description = "DeletePaymentTypesPaymentTypeIdResponse")
@@ -131,6 +131,6 @@ public final class PaymentTypeApiResourceSwagger {
private DeletePaymentTypesPaymentTypeIdResponse() {}
@Schema(example = "13")
- public Integer resourceId;
+ public Long resourceId;
}
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
index a29365722..55a6dcf9b 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientSavingsIntegrationTest.java
@@ -39,6 +39,8 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.GlobalConfigurationHelper;
@@ -80,6 +82,7 @@ public class ClientSavingsIntegrationTest {
private SavingsAccountHelper savingsAccountHelper;
private SavingsProductHelper savingsProductHelper;
private SchedulerJobHelper scheduleJobHelper;
+ private PaymentTypeHelper paymentTypeHelper;
@BeforeEach
public void setup() {
@@ -88,6 +91,7 @@ public class ClientSavingsIntegrationTest {
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
@Test
@@ -2639,8 +2643,9 @@ public class ClientSavingsIntegrationTest {
Boolean isCashPayment = false;
Integer position = 1;
- Integer paymentTypeIdOne =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, name,
description, isCashPayment,
- position);
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(
+ new
PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position));
+ Long paymentTypeIdOne = paymentTypesResponse.getResourceId();
Assertions.assertNotNull(paymentTypeIdOne);
final Integer chargeIdOne =
ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
@@ -2661,8 +2666,9 @@ public class ClientSavingsIntegrationTest {
String paymentTypeNameTwo =
PaymentTypeHelper.randomNameGenerator("P_T", 5);
- Integer paymentTypeIdTwo =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec,
paymentTypeNameTwo, description,
- isCashPayment, position);
+ PostPaymentTypesResponse paymentTypesResponseTwo =
paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest()
+
.name(paymentTypeNameTwo).description(description).isCashPayment(isCashPayment).position(position));
+ Long paymentTypeIdTwo = paymentTypesResponseTwo.getResourceId();
Assertions.assertNotNull(paymentTypeIdTwo);
final Integer chargeIdTwo =
ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
index ebc5d1319..3bcb868e2 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/GroupSavingsIntegrationTest.java
@@ -35,6 +35,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.GroupHelper;
@@ -65,6 +67,7 @@ public class GroupSavingsIntegrationTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private SavingsAccountHelper savingsAccountHelper;
+ private PaymentTypeHelper paymentTypeHelper;
private static final Logger LOG =
LoggerFactory.getLogger(GroupSavingsIntegrationTest.class);
@BeforeEach
@@ -74,6 +77,7 @@ public class GroupSavingsIntegrationTest {
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.requestSpec.header("Fineract-Platform-TenantId", "default");
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
@Test
@@ -313,7 +317,9 @@ public class GroupSavingsIntegrationTest {
Boolean isCashPayment = true;
Integer position = 1;
- Integer paymentTypeId =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, name,
description, isCashPayment, position);
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(
+ new
PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position));
+ Long paymentTypeId = paymentTypesResponse.getResourceId();
Assertions.assertNotNull(paymentTypeId);
List<Map<String, Object>> savingsArray = new ArrayList<>();
@@ -804,7 +810,7 @@ public class GroupSavingsIntegrationTest {
return map;
}
- private Map<String, Object> savingsArray(final Integer paymentId, final
Integer savingsId, final Integer transactionAmount,
+ private Map<String, Object> savingsArray(final Long paymentId, final
Integer savingsId, final Integer transactionAmount,
final String transactionDate) {
Map<String, Object> map = new HashMap<>();
map.put("transactionDate", transactionDate);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java
index f850df079..57cbaab09 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/LoanPostChargeOffScenariosTest.java
@@ -47,6 +47,8 @@ import
org.apache.fineract.client.models.PostLoanProductsRequest;
import org.apache.fineract.client.models.PostLoanProductsResponse;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsRequest;
import org.apache.fineract.client.models.PostLoansLoanIdTransactionsResponse;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
import org.apache.fineract.integrationtests.common.Utils;
@@ -79,6 +81,7 @@ public class LoanPostChargeOffScenariosTest {
private JournalEntryHelper journalEntryHelper;
private AccountHelper accountHelper;
private LoanProductHelper loanProductHelper;
+ private PaymentTypeHelper paymentTypeHelper;
// asset
private Account loansReceivable;
private Account interestFeeReceivable;
@@ -108,6 +111,7 @@ public class LoanPostChargeOffScenariosTest {
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.accountHelper = new AccountHelper(this.requestSpec,
this.responseSpec);
this.loanProductHelper = new LoanProductHelper();
+ this.paymentTypeHelper = new PaymentTypeHelper();
// Asset
this.loansReceivable = this.accountHelper.createAssetAccount();
@@ -1127,8 +1131,9 @@ public class LoanPostChargeOffScenariosTest {
Boolean isCashPayment = false;
Integer position = 1;
- Integer paymentTypeIdOne =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, paymentTypeName,
description,
- isCashPayment, position);
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(new PostPaymentTypesRequest()
+
.name(paymentTypeName).description(description).isCashPayment(isCashPayment).position(position));
+ Long paymentTypeIdOne = paymentTypesResponse.getResourceId();
Assertions.assertNotNull(paymentTypeIdOne);
List<GetLoanPaymentChannelToFundSourceMappings>
paymentChannelToFundSourceMappings = new ArrayList<>();
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java
index ef7cf27a8..062d4990c 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/PaymentTypeIntegrationTest.java
@@ -23,8 +23,11 @@ import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
-import java.util.HashMap;
-import org.apache.fineract.integrationtests.common.PaymentTypeDomain;
+import
org.apache.fineract.client.models.DeletePaymentTypesPaymentTypeIdResponse;
+import org.apache.fineract.client.models.GetPaymentTypesPaymentTypeIdResponse;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
+import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdRequest;
import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.jupiter.api.Assertions;
@@ -35,6 +38,7 @@ public class PaymentTypeIntegrationTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
+ private PaymentTypeHelper paymentTypeHelper;
@BeforeEach
public void setup() {
@@ -42,7 +46,7 @@ public class PaymentTypeIntegrationTest {
this.requestSpec = new
RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
-
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -53,10 +57,12 @@ public class PaymentTypeIntegrationTest {
Boolean isCashPayment = true;
Integer position = 1;
- Integer paymentTypeId =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, name,
description, isCashPayment, position);
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(
+ new
PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position));
+ Long paymentTypeId = paymentTypesResponse.getResourceId();
Assertions.assertNotNull(paymentTypeId);
- PaymentTypeHelper.verifyPaymentTypeCreatedOnServer(requestSpec,
responseSpec, paymentTypeId);
- PaymentTypeDomain paymentTypeResponse =
PaymentTypeHelper.retrieveById(requestSpec, responseSpec, paymentTypeId);
+ paymentTypeHelper.verifyPaymentTypeCreatedOnServer(paymentTypeId);
+ GetPaymentTypesPaymentTypeIdResponse paymentTypeResponse =
paymentTypeHelper.retrieveById(paymentTypeId);
Assertions.assertEquals(name, paymentTypeResponse.getName());
Assertions.assertEquals(description,
paymentTypeResponse.getDescription());
Assertions.assertEquals(isCashPayment,
paymentTypeResponse.getIsCashPayment());
@@ -68,24 +74,19 @@ public class PaymentTypeIntegrationTest {
Boolean isCashPaymentUpdatedValue = false;
Integer newPosition = 2;
- HashMap request = new HashMap();
- request.put("name", newName);
- request.put("description", newDescription);
- request.put("isCashPayment", isCashPaymentUpdatedValue);
- request.put("position", newPosition);
- PaymentTypeHelper.updatePaymentType(paymentTypeId, request,
requestSpec, responseSpec);
- PaymentTypeDomain paymentTypeUpdatedResponse =
PaymentTypeHelper.retrieveById(requestSpec, responseSpec, paymentTypeId);
+ paymentTypeHelper.updatePaymentType(paymentTypeId, new
PutPaymentTypesPaymentTypeIdRequest().name(newName)
+
.description(newDescription).isCashPayment(isCashPaymentUpdatedValue).position(newPosition));
+ GetPaymentTypesPaymentTypeIdResponse paymentTypeUpdatedResponse =
paymentTypeHelper.retrieveById(paymentTypeId);
Assertions.assertEquals(newName, paymentTypeUpdatedResponse.getName());
Assertions.assertEquals(newDescription,
paymentTypeUpdatedResponse.getDescription());
Assertions.assertEquals(isCashPaymentUpdatedValue,
paymentTypeUpdatedResponse.getIsCashPayment());
Assertions.assertEquals(newPosition,
paymentTypeUpdatedResponse.getPosition());
// Delete
- Integer deletedPaymentTypeId =
PaymentTypeHelper.deletePaymentType(paymentTypeId, requestSpec, responseSpec);
+ DeletePaymentTypesPaymentTypeIdResponse responseDelete =
paymentTypeHelper.deletePaymentType(paymentTypeId);
+ Long deletedPaymentTypeId = responseDelete.getResourceId();
Assertions.assertEquals(paymentTypeId, deletedPaymentTypeId);
ResponseSpecification responseSpecification = new
ResponseSpecBuilder().expectStatusCode(404).build();
- PaymentTypeHelper.retrieveById(requestSpec, responseSpecification,
paymentTypeId);
-
+ paymentTypeHelper.retrieveById(requestSpec, responseSpecification,
paymentTypeId);
}
-
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
index 684e4f020..b1f14e405 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/RepaymentWithPostDatedChecksTest.java
@@ -34,9 +34,11 @@ import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import org.apache.fineract.client.models.GetPaymentTypesPaymentTypeIdResponse;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
-import org.apache.fineract.integrationtests.common.PaymentTypeDomain;
import org.apache.fineract.integrationtests.common.PaymentTypeHelper;
import org.apache.fineract.integrationtests.common.Utils;
import
org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
@@ -56,6 +58,7 @@ public class RepaymentWithPostDatedChecksTest {
private RequestSpecification requestSpec;
private final SimpleDateFormat dateFormatterStandard = new
SimpleDateFormat("dd MMMM yyyy", Locale.US);
private LoanTransactionHelper loanTransactionHelper;
+ private PaymentTypeHelper paymentTypeHelper;
@BeforeEach
public void setup() {
@@ -63,6 +66,7 @@ public class RepaymentWithPostDatedChecksTest {
this.requestSpec = new
RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
@Test
@@ -136,10 +140,12 @@ public class RepaymentWithPostDatedChecksTest {
Boolean isCashPayment = false;
Integer position = 1;
- Integer paymentTypeId =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, name,
description, isCashPayment, position);
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(
+ new
PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position));
+ Long paymentTypeId = paymentTypesResponse.getResourceId();
Assertions.assertNotNull(paymentTypeId);
- PaymentTypeHelper.verifyPaymentTypeCreatedOnServer(requestSpec,
responseSpec, paymentTypeId);
- PaymentTypeDomain paymentTypeResponse =
PaymentTypeHelper.retrieveById(requestSpec, responseSpec, paymentTypeId);
+ paymentTypeHelper.verifyPaymentTypeCreatedOnServer(paymentTypeId);
+ GetPaymentTypesPaymentTypeIdResponse paymentTypeResponse =
paymentTypeHelper.retrieveById(paymentTypeId);
Assertions.assertEquals(name, paymentTypeResponse.getName());
// Repay for the installment 1 using post dated check
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
index 674b4273f..6b2753189 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/loan/LoanImportHandlerTest.java
@@ -41,6 +41,8 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants;
import
org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
@@ -75,6 +77,7 @@ public class LoanImportHandlerTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
+ private PaymentTypeHelper paymentTypeHelper;
@BeforeEach
public void setup() {
@@ -82,6 +85,7 @@ public class LoanImportHandlerTest {
this.requestSpec = new
RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
@Test
@@ -162,8 +166,11 @@ public class LoanImportHandlerTest {
String paymentTypeName = PaymentTypeHelper.randomNameGenerator("P_T",
5);
String paymentTypeDescription =
PaymentTypeHelper.randomNameGenerator("PT_Desc", 15);
- Integer outcome_payment_creation =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, paymentTypeName,
- paymentTypeDescription, true, 1);
+
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(
+ new
PostPaymentTypesRequest().name(paymentTypeName).description(paymentTypeDescription).isCashPayment(true).position(1));
+ Long outcome_payment_creation = paymentTypesResponse.getResourceId();
+
Assertions.assertNotNull(outcome_payment_creation, "Could not create
payment type");
LoanTransactionHelper loanTransactionHelper = new
LoanTransactionHelper(requestSpec, responseSpec);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
index 5710175cc..f2ea344b6 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/loan/LoanWorkbookPopulatorTest.java
@@ -26,6 +26,8 @@ import io.restassured.specification.ResponseSpecification;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import java.io.IOException;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
import
org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.GroupHelper;
@@ -47,6 +49,7 @@ public class LoanWorkbookPopulatorTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
+ private PaymentTypeHelper paymentTypeHelper;
@BeforeEach
public void setup() {
@@ -54,6 +57,7 @@ public class LoanWorkbookPopulatorTest {
this.requestSpec = new
RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " +
Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new
ResponseSpecBuilder().expectStatusCode(200).build();
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
@Test
@@ -90,8 +94,9 @@ public class LoanWorkbookPopulatorTest {
String description = PaymentTypeHelper.randomNameGenerator("PT_Desc",
15);
Boolean isCashPayment = true;
Integer position = 1;
- Integer outcome_payment_creation =
PaymentTypeHelper.createPaymentType(requestSpec, responseSpec, name,
description, isCashPayment,
- position);
+ PostPaymentTypesResponse paymentTypesResponse =
paymentTypeHelper.createPaymentType(
+ new
PostPaymentTypesRequest().name(name).description(description).isCashPayment(isCashPayment).position(position));
+ Long outcome_payment_creation = paymentTypesResponse.getResourceId();
Assertions.assertNotNull(outcome_payment_creation, "Could not create
payment type");
Workbook workbook = loanTransactionHelper.getLoanWorkbook("dd MMMM
yyyy");
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeDomain.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeDomain.java
index 846914c4c..c3ea6c3ca 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeDomain.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeDomain.java
@@ -20,13 +20,13 @@ package org.apache.fineract.integrationtests.common;
public final class PaymentTypeDomain {
- private Integer id;
+ private Long id;
private String name;
private String description;
private Boolean isCashPayment;
private Integer position;
- public PaymentTypeDomain(final Integer id, final String name, final String
description, final Boolean isCashPayment,
+ public PaymentTypeDomain(final Long id, final String name, final String
description, final Boolean isCashPayment,
final Integer position) {
this.id = id;
this.name = name;
@@ -36,11 +36,11 @@ public final class PaymentTypeDomain {
}
- public Integer getId() {
+ public Long getId() {
return this.id;
}
- public void setId(Integer id) {
+ public void setId(Long id) {
this.id = id;
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java
index 0f2c396dc..53465ed34 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/PaymentTypeHelper.java
@@ -24,97 +24,70 @@ import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import
org.apache.fineract.client.models.DeletePaymentTypesPaymentTypeIdResponse;
+import org.apache.fineract.client.models.GetPaymentTypesPaymentTypeIdResponse;
import org.apache.fineract.client.models.GetPaymentTypesResponse;
+import org.apache.fineract.client.models.PostPaymentTypesRequest;
+import org.apache.fineract.client.models.PostPaymentTypesResponse;
+import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdRequest;
+import org.apache.fineract.client.models.PutPaymentTypesPaymentTypeIdResponse;
+import org.apache.fineract.integrationtests.client.IntegrationTest;
@SuppressWarnings({ "rawtypes", "unchecked" })
-public final class PaymentTypeHelper {
+@Slf4j
+public final class PaymentTypeHelper extends IntegrationTest {
- private PaymentTypeHelper() {
+ public PaymentTypeHelper() {
}
private static final String PAYMENTTYPE_URL =
"/fineract-provider/api/v1/paymenttypes";
private static final String CREATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "?"
+ Utils.TENANT_IDENTIFIER;
- public static ArrayList<GetPaymentTypesResponse>
getSystemPaymentType(final RequestSpecification requestSpec,
- final ResponseSpecification responseSpec) {
- String response = Utils.performServerGet(requestSpec, responseSpec,
- PAYMENTTYPE_URL + "?onlyWithCode=true&" +
Utils.TENANT_IDENTIFIER);
- Type paymentTypeList = new
TypeToken<ArrayList<GetPaymentTypesResponse>>() {}.getType();
- return new Gson().fromJson(response, paymentTypeList);
+ public List<GetPaymentTypesResponse> getAllPaymentTypes(final Boolean
onlyWithCode) {
+ log.info("-------------------------------GETTING ALL PAYMENT
TYPES-------------------------------------------");
+ return ok(fineract().paymentTypes.getAllPaymentTypes(onlyWithCode));
}
- public static Integer createPaymentType(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec,
- final String name, final String description, final Boolean
isCashPayment, final Integer position) {
- // system.out.println("---------------------------------CREATING A
- // PAYMENT
- // TYPE---------------------------------------------");
- return Utils.performServerPost(requestSpec, responseSpec,
CREATE_PAYMENTTYPE_URL,
- getJsonToCreatePaymentType(name, description, isCashPayment,
position), "resourceId");
+ public PostPaymentTypesResponse createPaymentType(final
PostPaymentTypesRequest postPaymentTypesRequest) {
+ log.info("---------------------------------CREATING A PAYMENT
TYPE---------------------------------------------");
+ return
ok(fineract().paymentTypes.createPaymentType(postPaymentTypesRequest));
}
- public static String getJsonToCreatePaymentType(final String name, final
String description, final Boolean isCashPayment,
- final Integer position) {
- HashMap hm = new HashMap();
- hm.put("name", name);
- if (description != null) {
- hm.put("description", description);
- }
- hm.put("isCashPayment", isCashPayment);
- if (position != null) {
- hm.put("position", position);
- }
-
- // system.out.println("------------------------CREATING PAYMENT
- // TYPE-------------------------" + hm);
- return new Gson().toJson(hm);
+ public void verifyPaymentTypeCreatedOnServer(final Long
generatedPaymentTypeID) {
+ log.info("-------------------------------CHECK PAYMENT
DETAILS-------------------------------------------");
+ GetPaymentTypesPaymentTypeIdResponse response =
ok(fineract().paymentTypes.retrieveOnePaymentType(generatedPaymentTypeID));
+ Long responsePaymentTypeID = response.getId();
+ assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN
CREATING THE PAYMENT TYPE");
}
- public static void verifyPaymentTypeCreatedOnServer(final
RequestSpecification requestSpec, final ResponseSpecification responseSpec,
- final Integer generatedPaymentTypeID) {
- // system.out.println("------------------------------CHECK PAYMENT
- // DETAILS------------------------------------\n");
- final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" +
generatedPaymentTypeID + "?" + Utils.TENANT_IDENTIFIER;
- final Integer responsePaymentTypeID =
Utils.performServerGet(requestSpec, responseSpec, GET_PAYMENTTYPE_URL, "id");
- assertEquals(generatedPaymentTypeID, responsePaymentTypeID, "ERROR IN
CREATING THE PAYMENT TYPE");
+ public GetPaymentTypesPaymentTypeIdResponse retrieveById(final Long
paymentTypeId) {
+ log.info("-------------------------------GETTING PAYMENT
TYPE-------------------------------------------");
+ return
ok(fineract().paymentTypes.retrieveOnePaymentType(paymentTypeId));
}
- public static PaymentTypeDomain retrieveById(RequestSpecification
requestSpec, ResponseSpecification responseSpec,
- final Integer paymentTypeId) {
+ public PaymentTypeDomain retrieveById(RequestSpecification requestSpec,
ResponseSpecification responseSpec, final Long paymentTypeId) {
final String GET_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" +
paymentTypeId + "?" + Utils.TENANT_IDENTIFIER;
- // system.out.println("---------------------------------GET PAYMENT
- // TYPE---------------------------------------------");
+ log.info("-------------------------------GETTING PAYMENT
TYPE-------------------------------------------");
Object get = Utils.performServerGet(requestSpec, responseSpec,
GET_PAYMENTTYPE_URL, "");
final String jsonData = new Gson().toJson(get);
return new Gson().fromJson(jsonData, new
TypeToken<PaymentTypeDomain>() {}.getType());
-
}
- public static HashMap<String, String> updatePaymentType(final int id,
HashMap request, final RequestSpecification requestSpec,
- final ResponseSpecification responseSpec) {
- final String UPDATE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?"
+ Utils.TENANT_IDENTIFIER;
- // system.out.println("---------------------------------UPDATE PAYMENT
- // TYPE " +
- // id + "---------------------------------------------");
- HashMap<String, String> hash = Utils.performServerPut(requestSpec,
responseSpec, UPDATE_PAYMENTTYPE_URL, new Gson().toJson(request),
- "changes");
- return hash;
+ public PutPaymentTypesPaymentTypeIdResponse updatePaymentType(final Long
paymentTypeId,
+ PutPaymentTypesPaymentTypeIdRequest
putPaymentTypesPaymentTypeIdRequest) {
+ log.info("-------------------------------UPDATING PAYMENT
TYPE-------------------------------------------");
+ return ok(fineract().paymentTypes.updatePaymentType(paymentTypeId,
putPaymentTypesPaymentTypeIdRequest));
}
- public static Integer deletePaymentType(final int id, final
RequestSpecification requestSpec,
- final ResponseSpecification responseSpec) {
- final String DELETE_PAYMENTTYPE_URL = PAYMENTTYPE_URL + "/" + id + "?"
+ Utils.TENANT_IDENTIFIER;
- // system.out.println("---------------------------------DELETING
PAYMENT
- // TYPE "
- // + id + "--------------------------------------------");
- return Utils.performServerDelete(requestSpec, responseSpec,
DELETE_PAYMENTTYPE_URL, "resourceId");
+ public DeletePaymentTypesPaymentTypeIdResponse deletePaymentType(final
Long paymentTypeId) {
+ log.info("-------------------------------DELETING PAYMENT
TYPE-------------------------------------------");
+ return ok(fineract().paymentTypes.deleteCode1(paymentTypeId));
}
public static String randomNameGenerator(final String prefix, final int
lenOfRandomSuffix) {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix);
}
-
}
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
index ca1a10a26..3d1013a90 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
@@ -194,11 +194,11 @@ public final class ChargesHelper extends IntegrationTest {
return chargesCreateJson;
}
- public static String paymentTypeCharge(Integer amount, final boolean
enablePaymentType, final Integer paymentTypeId) {
+ public static String paymentTypeCharge(Integer amount, final boolean
enablePaymentType, final Long paymentTypeId) {
return paymentTypeChargeJSON(amount, enablePaymentType, paymentTypeId);
}
- public static String paymentTypeChargeJSON(Integer amount, final boolean
enablePaymentType, final Integer paymentTypeId) {
+ public static String paymentTypeChargeJSON(Integer amount, final boolean
enablePaymentType, final Long paymentTypeId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.ACTIVE);
map.put("amount", amount);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
index b162694cd..314769d1e 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
@@ -112,10 +112,12 @@ public class LoanTransactionHelper extends
IntegrationTest {
private static final Gson GSON = new JSON().getGson();
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
+ private PaymentTypeHelper paymentTypeHelper;
public LoanTransactionHelper(final RequestSpecification requestSpec, final
ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
+ this.paymentTypeHelper = new PaymentTypeHelper();
}
public GetLoanProductsProductIdResponse getLoanProduct(final Integer
loanProductId) {
@@ -745,7 +747,7 @@ public class LoanTransactionHelper extends IntegrationTest {
return ok(fineract().loanTransactions.adjustLoanTransaction(loanId,
transactionId, request, "undo"));
}
- public HashMap makeRepaymentWithPDC(final String date, final Float
amountToBePaid, final Integer loanID, final Integer paymentType) {
+ public HashMap makeRepaymentWithPDC(final String date, final Float
amountToBePaid, final Integer loanID, final Long paymentType) {
return (HashMap)
performLoanTransaction(createLoanTransactionURL(MAKE_REPAYMENT_COMMAND, loanID),
getRepaymentWithPDCBodyAsJSON(date, amountToBePaid,
paymentType), "");
}
@@ -1123,7 +1125,7 @@ public class LoanTransactionHelper extends
IntegrationTest {
return new Gson().toJson(map);
}
- private String getRepaymentWithPDCBodyAsJSON(final String transactionDate,
final Float transactionAmount, final Integer paymentTypeId) {
+ private String getRepaymentWithPDCBodyAsJSON(final String transactionDate,
final Float transactionAmount, final Long paymentTypeId) {
final HashMap<String, String> map = new HashMap<>();
map.put("locale", "en");
map.put("paymentTypeId", paymentTypeId.toString());
@@ -1692,7 +1694,7 @@ public class LoanTransactionHelper extends
IntegrationTest {
public Long applyChargebackTransaction(final Integer loanId, final Long
transactionId, final String amount,
final Integer paymentTypeIdx, ResponseSpecification responseSpec) {
- List<GetPaymentTypesResponse> paymentTypeList =
PaymentTypeHelper.getSystemPaymentType(this.requestSpec, this.responseSpec);
+ List<GetPaymentTypesResponse> paymentTypeList =
paymentTypeHelper.getAllPaymentTypes(false);
assertTrue(!paymentTypeList.isEmpty());
final String payload = createChargebackPayload(amount,
paymentTypeList.get(paymentTypeIdx).getId());
@@ -1722,7 +1724,7 @@ public class LoanTransactionHelper extends
IntegrationTest {
}
}
- private String createChargebackPayload(final String transactionAmount,
final Integer paymentTypeId) {
+ private String createChargebackPayload(final String transactionAmount,
final Long paymentTypeId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("transactionAmount", transactionAmount);
map.put("paymentTypeId", paymentTypeId);