FINERACT-1724 swagger fix

This commit is contained in:
Peter Kovacs
2023-07-17 11:25:07 +02:00
committed by Adam Saghy
parent be935cd55b
commit 948af9ab2b
13 changed files with 125 additions and 114 deletions
@@ -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);
@@ -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;
}
}
@@ -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,
@@ -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);
@@ -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<>();
@@ -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);
}
}
@@ -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
@@ -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);
@@ -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");
@@ -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;
}
@@ -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 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");
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 PaymentTypeDomain retrieveById(RequestSpecification requestSpec, ResponseSpecification responseSpec,
final Integer paymentTypeId) {
public GetPaymentTypesPaymentTypeIdResponse retrieveById(final Long paymentTypeId) {
log.info("-------------------------------GETTING PAYMENT TYPE-------------------------------------------");
return ok(fineract().paymentTypes.retrieveOnePaymentType(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);
}
}
@@ -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);
@@ -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);