Integration test cases for Entity-Datatable Check

This commit is contained in:
Satish
2016-12-20 16:53:31 +05:30
parent 9cc60c9b7e
commit c8cedfc70d
9 changed files with 870 additions and 19 deletions
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.integrationtests.common.system.CodeHelper;
import com.google.gson.Gson;
@@ -53,7 +53,7 @@ public class ClientHelper {
public static final String TRANSACTION_DATE = "01 March 2013";
public static final String LAST_TRANSACTION_DATE = "01 March 2013";
public static final String DATE_FORMAT = "dd MMMM yyyy";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public ClientHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
@@ -93,9 +93,20 @@ public class ClientHelper {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL, getTestClientAsJSONPending(submittedOnDate, officeId),
"clientId");
}
public Object createClientPendingWithError(final String jsonAttributeToGetBack) {
System.out.println("---------------------------------CREATING A CLIENT IN PENDING WITH ERROR---------------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_CLIENT_URL,
getTestClientAsJSONPending("04 March 2014", "1"), jsonAttributeToGetBack);
}
public static Integer createClientPendingWithDatatable(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String registeredTableName) {
System.out.println("-------------------------- CREATING A CLIENT IN PENDING WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
getTestPendingClientWithDatatableAsJson(registeredTableName), "clientId");
}
public static Integer createClientAsPerson(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
return createClientAsPerson(requestSpec, responseSpec, "04 March 2011");
}
@@ -184,10 +195,39 @@ public class ClientHelper {
System.out.println("map : " + map);
return new Gson().toJson(map);
}
public static String getTestPendingClientWithDatatableAsJson(final String registeredTableName) {
final HashMap<String, Object> map = new HashMap<>();
map.put("officeId", "1");
map.put("firstname", Utils.randomNameGenerator("Client_FirstName_", 5));
map.put("lastname", Utils.randomNameGenerator("Client_LastName_", 4));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", DATE_FORMAT);
map.put("locale", "en");
map.put("active", "false");
map.put("submittedOnDate", "04 March 2014");
String requestJson = getTestDatatableAsJson(map, registeredTableName);
System.out.println("map : " + requestJson);
return requestJson;
}
public static String getTestDatatableAsJson(HashMap<String, Object> map, final String registeredTableName) {
List<HashMap<String, Object>> datatablesListMap = new ArrayList<>();
HashMap<String, Object> datatableMap = new HashMap<>();
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("locale", "en");
dataMap.put("Spouse Name", Utils.randomNameGenerator("Spouse_name", 4));
dataMap.put("Number of Dependents", 5);
dataMap.put("Time of Visit", "01 December 2016 04:03");
dataMap.put("dateFormat", DATE_TIME_FORMAT);
dataMap.put("Date of Approval", "02 December 2016 00:00");
datatableMap.put("registeredTableName", registeredTableName);
datatableMap.put("data", dataMap);
datatablesListMap.add(datatableMap);
map.put("datatables", datatablesListMap);
return new Gson().toJson(map);
}
public static String getTestPersonClientAsJSON(final String dateOfJoining, final String officeId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("officeId", officeId);
@@ -34,7 +34,17 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class GroupHelper {
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
private static final String CREATE_GROUP_URL = "/fineract-provider/api/v1/groups?" + Utils.TENANT_IDENTIFIER;
public static final String DATE_FORMAT = "dd MMMM yyyy";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public GroupHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
}
public static Integer createGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
@SuppressWarnings("unused") final boolean active) {
@@ -53,6 +63,19 @@ public class GroupHelper {
return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL, getTestGroupAsJSON(false, ""), "groupId");
}
public Object createGroupWithError(final String jsonAttributeToGetBack) {
System.out.println("---------------------------------CREATING A GROUP WITH ERROR---------------------------------------------");
return Utils.performServerPost(this.requestSpec, this.responseSpec, CREATE_GROUP_URL, getTestGroupAsJSON(false, ""),
jsonAttributeToGetBack);
}
public static Integer createGroupPendingWithDatatable(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec, final String registeredTableName) {
System.out.println("-------------------------- CREATING A GROUP WITH DATATABLES --------------------------------");
return Utils.performServerPost(requestSpec, responseSpec, CREATE_GROUP_URL,
getTestGroupWithDatatableAsJson(registeredTableName), "groupId");
}
public static Integer associateClient(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String groupId, final String clientMember) {
final String GROUP_ASSOCIATE_URL = "/fineract-provider/api/v1/groups/" + groupId
@@ -227,4 +250,35 @@ public class GroupHelper {
private static String randomIDGenerator(final String prefix, final int lenOfRandomSuffix) {
return Utils.randomStringGenerator(prefix, lenOfRandomSuffix, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
}
public static String getTestGroupWithDatatableAsJson(final String registeredTableName) {
final HashMap<String, Object> map = new HashMap<>();
map.put("officeId", "1");
map.put("name", randomNameGenerator("Group_Name_", 5));
map.put("externalId", randomIDGenerator("ID_", 7));
map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en");
map.put("active", "false");
map.put("submittedOnDate", "04 March 2011");
String requestJson = getTestDatatableAsJson(map, registeredTableName);
System.out.println("map : " + requestJson);
return requestJson;
}
public static String getTestDatatableAsJson(HashMap<String, Object> map, final String registeredTableName) {
List<HashMap<String, Object>> datatablesListMap = new ArrayList<>();
HashMap<String, Object> datatableMap = new HashMap<>();
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("locale", "en");
dataMap.put("Spouse Name", Utils.randomNameGenerator("Spouse_name", 4));
dataMap.put("Number of Dependents", 5);
dataMap.put("Time of Visit", "01 December 2016 04:03");
dataMap.put("dateFormat", DATE_TIME_FORMAT);
dataMap.put("Date of Approval", "02 December 2016 00:00");
datatableMap.put("registeredTableName", registeredTableName);
datatableMap.put("data", dataMap);
datatablesListMap.add(datatableMap);
map.put("datatables", datatablesListMap);
return new Gson().toJson(map);
}
}
@@ -65,6 +65,7 @@ public class LoanApplicationTestBuilder {
private String calendarId;
private boolean syncDisbursementWithMeeting = false;
private List<HashMap<String, Object>> datatables = null;
public String build(final String clientID, final String groupID, final String loanProductId, final String savingsID) {
final HashMap<String, Object> map = new HashMap<>();
@@ -134,6 +135,9 @@ public class LoanApplicationTestBuilder {
}
if (datatables != null) {
map.put("datatables", this.datatables);
}
System.out.println("Loan Application request : " + map);
return new Gson().toJson(map);
}
@@ -311,4 +315,9 @@ public class LoanApplicationTestBuilder {
this.fixedEmiAmount = installmentAmount;
return this;
}
public LoanApplicationTestBuilder withDatatables(final List<HashMap<String, Object>> datatables) {
this.datatables = datatables;
return this;
}
}
@@ -55,6 +55,8 @@ public class LoanTransactionHelper {
private static final String MAKE_REFUND_BY_CASH_COMMAND = "refundByCash";
private static final String FORECLOSURE_COMMAND = "foreclosure";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public LoanTransactionHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
@@ -68,6 +70,10 @@ public class LoanTransactionHelper {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, "loanId");
}
public Object getLoanError(final String loanApplicationJSON, final String responseAttribute) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, APPLY_LOAN_URL, loanApplicationJSON, responseAttribute);
}
public Integer getLoanOfficerId(final String loanId) {
final String GET_LOAN_URL = "/fineract-provider/api/v1/loans/" + loanId + "?" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(this.requestSpec, this.responseSpec, GET_LOAN_URL, "loanOfficerId");
@@ -672,4 +678,20 @@ public class LoanTransactionHelper {
System.out.println(json);
return json;
}
public static List<HashMap<String, Object>> getTestDatatableAsJson(final String registeredTableName) {
List<HashMap<String, Object>> datatablesListMap = new ArrayList<>();
HashMap<String, Object> datatableMap = new HashMap<>();
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("locale", "en");
dataMap.put("Spouse Name", Utils.randomNameGenerator("Spouse_name", 4));
dataMap.put("Number of Dependents", 5);
dataMap.put("Time of Visit", "01 December 2016 04:03");
dataMap.put("dateFormat", DATE_TIME_FORMAT);
dataMap.put("Date of Approval", "02 December 2016 00:00");
datatableMap.put("registeredTableName", registeredTableName);
datatableMap.put("data", dataMap);
datatablesListMap.add(datatableMap);
return datatablesListMap;
}
}
@@ -0,0 +1,68 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.integrationtests.common.organisation;
import java.util.HashMap;
import org.apache.fineract.integrationtests.common.Utils;
import com.google.gson.Gson;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
public class EntityDatatableChecksHelper {
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
private static final String DATATABLE_CHECK_URL = "/fineract-provider/api/v1/entityDatatableChecks";
public EntityDatatableChecksHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
}
public Integer createEntityDatatableCheck(final String apptableName, final String datatableName, final int status, final Integer productId) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, DATATABLE_CHECK_URL + "?" + Utils.TENANT_IDENTIFIER,
getTestEdcAsJSON(apptableName, datatableName, status, productId), "resourceId");
}
public Integer deleteEntityDatatableCheck(final Integer entityDatatableCheckId) {
return Utils.performServerDelete(requestSpec, responseSpec, DATATABLE_CHECK_URL + "/" + entityDatatableCheckId + "?"
+ Utils.TENANT_IDENTIFIER, "resourceId");
}
public String retrieveEntityDatatableCheck() {
return Utils.performServerGet(requestSpec, responseSpec, DATATABLE_CHECK_URL + "?" + Utils.TENANT_IDENTIFIER, null);
}
public static String getTestEdcAsJSON(final String apptableName, final String datatableName, final int status, final Integer productId) {
final HashMap<String, Object> map = new HashMap<>();
map.put("entity", apptableName);
map.put("status", status);
map.put("datatableName", datatableName);
if (productId != null) {
map.put("productId", productId);
}
String requestJsonString = new Gson().toJson(map);
System.out.println("map : " + requestJsonString);
return requestJsonString;
}
}
@@ -0,0 +1,509 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.integrationtests.common.organisation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CommonConstants;
import org.apache.fineract.integrationtests.common.GroupHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.apache.fineract.integrationtests.common.loans.LoanApplicationTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanProductTestBuilder;
import org.apache.fineract.integrationtests.common.loans.LoanTransactionHelper;
import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
import org.apache.fineract.integrationtests.common.system.DatatableHelper;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.builder.ResponseSpecBuilder;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
/**
* Entity Datatable Checks Integration Test for checking Creation, Deletion and
* Retrieval of Entity-Datatable Check
*/
public class EntityDatatableChecksIntegrationTest {
private RequestSpecification requestSpec;
private ResponseSpecification responseSpec;
private EntityDatatableChecksHelper entityDatatableChecksHelper;
private DatatableHelper datatableHelper;
private SavingsAccountHelper savingsAccountHelper;
private LoanTransactionHelper loanTransactionHelper;
private LoanTransactionHelper validationErrorHelper;
private static final String CLIENT_APP_TABLE_NAME = "m_client";
private static final String GROUP_APP_TABLE_NAME = "m_group";
private static final String SAVINGS_APP_TABLE_NAME = "m_savings_account";
private static final String LOAN_APP_TABLE_NAME = "m_loan";
public static final String MINIMUM_OPENING_BALANCE = "1000.0";
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public EntityDatatableChecksIntegrationTest() {
// TODO Auto-generated constructor stub
}
@Before
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
this.entityDatatableChecksHelper = new EntityDatatableChecksHelper(this.requestSpec, this.responseSpec);
this.datatableHelper = new DatatableHelper(this.requestSpec, this.responseSpec);
}
@Test
public void validateCreateDeleteEntityDatatableCheck() {
// creating datatable
String datatableName = this.datatableHelper.createDatatable(CLIENT_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, datatableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableName,
100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(datatableName);
assertEquals("ERROR IN DELETING THE DATATABLE", datatableName, deletedDataTableName);
}
@Test
public void validateRetriveEntityDatatableChecksList() {
// retrieving entity datatable check
String entityDatatableChecksList = this.entityDatatableChecksHelper.retrieveEntityDatatableCheck();
assertNotNull("ERROR IN RETRIEVING THE ENTITY DATATABLE CHECKS", entityDatatableChecksList);
}
@Test
public void validateCreateClientWithEntityDatatableCheck() {
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(CLIENT_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(CLIENT_APP_TABLE_NAME,
registeredTableName, 100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// creating client with datatables
final Integer clientID = ClientHelper.createClientPendingWithDatatable(requestSpec, responseSpec, registeredTableName);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting datatable entries
Integer appTableId = this.datatableHelper.deleteDatatableEntries(registeredTableName, clientID, "clientId");
assertEquals("ERROR IN DELETING THE DATATABLE ENTRIES", clientID, appTableId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@SuppressWarnings("unchecked")
@Test
public void validateCreateClientWithEntityDatatableCheckWithFailure() {
// building error response with status code 403
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
final ClientHelper validationErrorHelper = new ClientHelper(this.requestSpec, errorResponse);
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(CLIENT_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(CLIENT_APP_TABLE_NAME,
registeredTableName, 100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// creating client with datatables with error
ArrayList<HashMap<Object, Object>> clientErrorData = (ArrayList<HashMap<Object, Object>>) validationErrorHelper
.createClientPendingWithError(CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.entry.required.in.datatable.[" + registeredTableName + "]",
clientErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@Test
public void validateCreateGroupWithEntityDatatableCheck() {
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(GROUP_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(GROUP_APP_TABLE_NAME,
registeredTableName, 100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// creating group with datatables
final Integer groupId = GroupHelper.createGroupPendingWithDatatable(this.requestSpec, this.responseSpec, registeredTableName);
GroupHelper.verifyGroupCreatedOnServer(this.requestSpec, this.responseSpec, groupId);
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting datatable entries
Integer appTableId = this.datatableHelper.deleteDatatableEntries(registeredTableName, groupId, "groupId");
assertEquals("ERROR IN DELETING THE DATATABLE ENTRIES", groupId, appTableId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@SuppressWarnings("unchecked")
@Test
public void validateCreateGroupWithEntityDatatableCheckWithFailure() {
// building error response with status code 403
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
final GroupHelper validationErrorHelper = new GroupHelper(this.requestSpec, errorResponse);
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(GROUP_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(GROUP_APP_TABLE_NAME,
registeredTableName, 100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// creating group with datatables with error
ArrayList<HashMap<Object, Object>> groupErrorData = (ArrayList<HashMap<Object, Object>>) validationErrorHelper
.createGroupWithError(CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.entry.required.in.datatable.[" + registeredTableName + "]",
groupErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@Test
public void validateCreateSavingsWithEntityDatatableCheck() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
final String minBalanceForInterestCalculation = null;
final String minRequiredBalance = null;
final String enforceMinRequiredBalance = "false";
final boolean allowOverdraft = false;
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(SAVINGS_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(SAVINGS_APP_TABLE_NAME,
registeredTableName, 100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
Assert.assertNotNull(savingsProductID);
// creating savings with datatables
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationWithDatatables(clientID, savingsProductID,
ACCOUNT_TYPE_INDIVIDUAL, "01 December 2016", registeredTableName);
Assert.assertNotNull(savingsId);
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting datatable entries
Integer appTableId = this.datatableHelper.deleteDatatableEntries(registeredTableName, savingsId, "savingsId");
assertEquals("ERROR IN DELETING THE DATATABLE ENTRIES", savingsId, appTableId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@SuppressWarnings("unchecked")
@Test
public void validateCreateSavingsWithEntityDatatableCheckWithFailure() {
// building error response with status code 403
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
final String minBalanceForInterestCalculation = null;
final String minRequiredBalance = null;
final String enforceMinRequiredBalance = "false";
final boolean allowOverdraft = false;
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(SAVINGS_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(SAVINGS_APP_TABLE_NAME,
registeredTableName, 100, null);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance, allowOverdraft);
Assert.assertNotNull(savingsProductID);
// creating savings with datatables with error
ArrayList<HashMap<Object, Object>> groupErrorData = (ArrayList<HashMap<Object, Object>>) validationErrorHelper
.applyForSavingsApplicationWithFailure(clientID, savingsProductID, ACCOUNT_TYPE_INDIVIDUAL, "01 December 2016",
CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.entry.required.in.datatable.[" + registeredTableName + "]",
groupErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@Test
public void validateCreateLoanWithEntityDatatableCheck() {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
// creating client
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// creating loan product
final Integer loanProductID = createLoanProduct("100", "0", LoanProductTestBuilder.DEFAULT_STRATEGY);
Assert.assertNotNull(loanProductID);
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(LOAN_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(LOAN_APP_TABLE_NAME,
registeredTableName, 100, loanProductID);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// creating new loan application
final Integer loanID = applyForLoanApplication(clientID, loanProductID, "5", registeredTableName);
Assert.assertNotNull(loanID);
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting datatable entries
Integer appTableId = this.datatableHelper.deleteDatatableEntries(registeredTableName, loanID, "loanId");
assertEquals("ERROR IN DELETING THE DATATABLE ENTRIES", loanID, appTableId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
@SuppressWarnings("unchecked")
@Test
public void validateCreateLoanWithEntityDatatableCheckWithFailure() {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
// building error response with status code 403
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(403).build();
this.validationErrorHelper = new LoanTransactionHelper(this.requestSpec, errorResponse);
// creating client
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
// creating loan product
final Integer loanProductID = createLoanProduct("100", "0", LoanProductTestBuilder.DEFAULT_STRATEGY);
Assert.assertNotNull(loanProductID);
// creating datatable
String registeredTableName = this.datatableHelper.createDatatable(LOAN_APP_TABLE_NAME, false);
DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, this.responseSpec, registeredTableName);
// creating new entity datatable check
Integer entityDatatableCheckId = this.entityDatatableChecksHelper.createEntityDatatableCheck(LOAN_APP_TABLE_NAME,
registeredTableName, 100, loanProductID);
assertNotNull("ERROR IN CREATING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// creating new loan application with error
ArrayList<HashMap<Object, Object>> loanErrorData = (ArrayList<HashMap<Object, Object>>) applyForLoanApplicationWithError(clientID,
loanProductID, "5", CommonConstants.RESPONSE_ERROR);
assertEquals("error.msg.entry.required.in.datatable.[" + registeredTableName + "]",
loanErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
// deleting entity datatable check
entityDatatableCheckId = this.entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheckId);
assertNotNull("ERROR IN DELETING THE ENTITY DATATABLE CHECK", entityDatatableCheckId);
// deleting the datatable
String deletedDataTableName = this.datatableHelper.deleteDatatable(registeredTableName);
assertEquals("ERROR IN DELETING THE DATATABLE", registeredTableName, deletedDataTableName);
}
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance,
String enforceMinRequiredBalance, final boolean allowOverdraft) {
final String taxGroupId = null;
return createSavingsProduct(requestSpec, responseSpec, minOpenningBalance, minBalanceForInterestCalculation, minRequiredBalance,
enforceMinRequiredBalance, allowOverdraft, taxGroupId, false);
}
private Integer createSavingsProduct(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String minOpenningBalance, String minBalanceForInterestCalculation, String minRequiredBalance,
String enforceMinRequiredBalance, final boolean allowOverdraft, final String taxGroupId, boolean withDormancy) {
System.out.println("------------------------------CREATING NEW SAVINGS PRODUCT ---------------------------------------");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
if (allowOverdraft) {
final String overDraftLimit = "2000.0";
savingsProductHelper = savingsProductHelper.withOverDraft(overDraftLimit);
}
if (withDormancy) {
savingsProductHelper = savingsProductHelper.withDormancy();
}
final String savingsProductJSON = savingsProductHelper
//
.withInterestCompoundingPeriodTypeAsDaily()
//
.withInterestPostingPeriodTypeAsMonthly()
//
.withInterestCalculationPeriodTypeAsDailyBalance()
//
.withMinBalanceForInterestCalculation(minBalanceForInterestCalculation)
//
.withMinRequiredBalance(minRequiredBalance).withEnforceMinRequiredBalance(enforceMinRequiredBalance)
.withMinimumOpenningBalance(minOpenningBalance).withWithHoldTax(taxGroupId).build();
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
}
private Integer createLoanProduct(final String inMultiplesOf, final String digitsAfterDecimal, final String repaymentStrategy) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
final String loanProductJSON = new LoanProductTestBuilder() //
.withPrincipal("10000000.00") //
.withNumberOfRepayments("24") //
.withRepaymentAfterEvery("1") //
.withRepaymentTypeAsMonth() //
.withinterestRatePerPeriod("2") //
.withInterestRateFrequencyTypeAsMonths() //
.withRepaymentStrategy(repaymentStrategy) //
.withAmortizationTypeAsEqualPrincipalPayment() //
.withInterestTypeAsDecliningBalance() //
.currencyDetails(digitsAfterDecimal, inMultiplesOf).build(null);
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
private Integer applyForLoanApplication(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment,
final String registeredTableName) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000000.00") //
.withLoanTermFrequency("24") //
.withLoanTermFrequencyAsMonths() //
.withNumberOfRepayments("24") //
.withRepaymentEveryAfter("1") //
.withRepaymentFrequencyTypeAsMonths() //
.withInterestRatePerPeriod("2") //
.withAmortizationTypeAsEqualPrincipalPayments() //
.withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withPrincipalGrace(graceOnPrincipalPayment).withExpectedDisbursementDate("2 June 2014") //
.withSubmittedOnDate("2 June 2014") //
.withDatatables(getTestDatatableAsJson(registeredTableName)) //
.build(clientID.toString(), loanProductID.toString(), null);
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
}
private Object applyForLoanApplicationWithError(final Integer clientID, final Integer loanProductID, String graceOnPrincipalPayment,
final String responseAttribute) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder() //
.withPrincipal("10000000.00") //
.withLoanTermFrequency("24") //
.withLoanTermFrequencyAsMonths() //
.withNumberOfRepayments("24") //
.withRepaymentEveryAfter("1") //
.withRepaymentFrequencyTypeAsMonths() //
.withInterestRatePerPeriod("2") //
.withAmortizationTypeAsEqualPrincipalPayments() //
.withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
.withPrincipalGrace(graceOnPrincipalPayment).withExpectedDisbursementDate("2 June 2014") //
.withSubmittedOnDate("2 June 2014") //
.build(clientID.toString(), loanProductID.toString(), null);
return this.validationErrorHelper.getLoanError(loanApplicationJSON, responseAttribute);
}
public static List<HashMap<String, Object>> getTestDatatableAsJson(final String registeredTableName) {
List<HashMap<String, Object>> datatablesListMap = new ArrayList<>();
HashMap<String, Object> datatableMap = new HashMap<>();
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("locale", "en");
dataMap.put("Spouse Name", Utils.randomNameGenerator("Spouse_name", 4));
dataMap.put("Number of Dependents", 5);
dataMap.put("Time of Visit", "01 December 2016 04:03");
dataMap.put("dateFormat", DATE_TIME_FORMAT);
dataMap.put("Date of Approval", "02 December 2016 00:00");
datatableMap.put("registeredTableName", registeredTableName);
datatableMap.put("data", dataMap);
datatablesListMap.add(datatableMap);
return datatablesListMap;
}
}
@@ -63,6 +63,8 @@ public class SavingsAccountHelper {
public static final String LAST_TRANSACTION_DATE = "01 March 2013";
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
public static final String DATE_TIME_FORMAT = "dd MMMM yyyy HH:mm";
public SavingsAccountHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
@@ -89,6 +91,27 @@ public class SavingsAccountHelper {
savingsApplicationJSON, "savingsId");
}
public Integer applyForSavingsApplicationWithDatatables(final Integer ID, final Integer savingsProductID, final String accountType,
final String submittedOnDate, final String datatableName) {
System.out.println("----------------------------APPLYING FOR SAVINGS APPLICATION WITH DATATABLES----------------------------");
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
.withSubmittedOnDate(submittedOnDate) //
.withDatatables(getTestDatatableAsJson(datatableName)) //
.build(ID.toString(), savingsProductID.toString(), accountType);
return Utils.performServerPost(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER,
savingsApplicationJSON, "savingsId");
}
public Object applyForSavingsApplicationWithFailure(final Integer ID, final Integer savingsProductID, final String accountType,
final String submittedOnDate, final String responseAttribute) {
System.out.println("----------------------------APPLYING FOR SAVINGS APPLICATION WITH ERROR----------------------------");
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
.withSubmittedOnDate(submittedOnDate) //
.build(ID.toString(), savingsProductID.toString(), accountType);
return Utils.performServerPost(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER,
savingsApplicationJSON, responseAttribute);
}
public HashMap updateSavingsAccount(final Integer ID, final Integer savingsProductID, final Integer savingsId, final String accountType) {
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
.withSubmittedOnDate(CREATED_DATE_PLUS_ONE) //
@@ -536,4 +559,19 @@ public class SavingsAccountHelper {
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
}
public static List<HashMap<String, Object>> getTestDatatableAsJson(final String registeredTableName) {
List<HashMap<String, Object>> datatablesListMap = new ArrayList<>();
HashMap<String, Object> datatableMap = new HashMap<>();
HashMap<String, Object> dataMap = new HashMap<>();
dataMap.put("locale", "en");
dataMap.put("Spouse Name", Utils.randomNameGenerator("Spouse_name", 4));
dataMap.put("Number of Dependents", 5);
dataMap.put("Time of Visit", "01 December 2016 04:03");
dataMap.put("dateFormat", DATE_TIME_FORMAT);
dataMap.put("Date of Approval", "02 December 2016 00:00");
datatableMap.put("registeredTableName", registeredTableName);
datatableMap.put("data", dataMap);
datatablesListMap.add(datatableMap);
return datatablesListMap;
}
}
@@ -19,6 +19,7 @@
package org.apache.fineract.integrationtests.common.savings;
import java.util.HashMap;
import java.util.List;
import com.google.gson.Gson;
@@ -27,23 +28,28 @@ public class SavingsApplicationTestBuilder {
private static final String LOCALE = "en_GB";
private String submittedOnDate = "";
private HashMap<String, String> addParams = null;
private List<HashMap<String, Object>> datatables = null;
public String build(final String ID, final String savingsProductId, final String accountType) {
final HashMap<String, String> map = new HashMap<>();
final HashMap<String, Object> map = new HashMap<>();
map.put("dateFormat", "dd MMMM yyyy");
if (accountType == "GROUP") {
map.put("groupId", ID);
} else {
map.put("clientId", ID);
}
}
map.put("productId", savingsProductId);
map.put("locale", LOCALE);
map.put("submittedOnDate", this.submittedOnDate);
if(addParams!=null && addParams.size() > 0){
map.putAll(addParams);
if (addParams != null && addParams.size() > 0) {
map.putAll(addParams);
}
if (datatables != null) {
map.put("datatables", this.datatables);
}
String savingsApplicationJSON = new Gson().toJson(map);
System.out.println(savingsApplicationJSON);
@@ -55,9 +61,13 @@ public class SavingsApplicationTestBuilder {
return this;
}
public SavingsApplicationTestBuilder withParams(
HashMap<String, String> params) {
this.addParams = params;
return this;
}
public SavingsApplicationTestBuilder withParams(HashMap<String, String> params) {
this.addParams = params;
return this;
}
public SavingsApplicationTestBuilder withDatatables(final List<HashMap<String, Object>> datatables) {
this.datatables = datatables;
return this;
}
}
@@ -0,0 +1,101 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.integrationtests.common.system;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.apache.fineract.integrationtests.common.Utils;
import com.google.gson.Gson;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
public class DatatableHelper {
private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec;
private static final String DATATABLE_URL = "/fineract-provider/api/v1/datatables";
public DatatableHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
}
public String createDatatable(final String apptableName, final boolean multiRow) {
return Utils.performServerPost(this.requestSpec, this.responseSpec, DATATABLE_URL + "?" + Utils.TENANT_IDENTIFIER,
getTestDatatableAsJSON(apptableName, multiRow), "resourceIdentifier");
}
public String deleteDatatable(final String datatableName) {
return Utils.performServerDelete(this.requestSpec, this.responseSpec, DATATABLE_URL + "/" + datatableName + "?" + Utils.TENANT_IDENTIFIER,
"resourceIdentifier");
}
public Integer deleteDatatableEntries(final String datatableName, final Integer apptableId, String jsonAttributeToGetBack) {
final String deleteEntryUrl = DATATABLE_URL + "/" + datatableName + "/" + apptableId + "?genericResultSet=true" + "&"
+ Utils.TENANT_IDENTIFIER;
return Utils.performServerDelete(this.requestSpec, this.responseSpec, deleteEntryUrl, jsonAttributeToGetBack);
}
public static void verifyDatatableCreatedOnServer(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final String generatedDatatableName) {
System.out.println("------------------------------CHECK DATATABLE DETAILS------------------------------------\n");
final String responseRegisteredTableName = Utils.performServerGet(requestSpec, responseSpec, DATATABLE_URL + "/"
+ generatedDatatableName + "?" + Utils.TENANT_IDENTIFIER, "registeredTableName");
assertEquals("ERROR IN CREATING THE DATATABLE", generatedDatatableName, responseRegisteredTableName);
}
public static String getTestDatatableAsJSON(final String apptableName, final boolean multiRow) {
final HashMap<String, Object> map = new HashMap<>();
final List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
map.put("datatableName", Utils.randomNameGenerator(apptableName + "_", 5));
map.put("apptableName", apptableName);
map.put("multiRow", multiRow);
addDatatableColumns(datatableColumnsList, "Spouse Name", "String", true, 25);
addDatatableColumns(datatableColumnsList, "Number of Dependents", "Number", true, null);
addDatatableColumns(datatableColumnsList, "Time of Visit", "DateTime", false, null);
addDatatableColumns(datatableColumnsList, "Date of Approval", "Date", false, null);
map.put("columns", datatableColumnsList);
String requestJsonString = new Gson().toJson(map);
System.out.println("map : " + requestJsonString);
return requestJsonString;
}
public static List<HashMap<String, Object>> addDatatableColumns(List<HashMap<String, Object>> datatableColumnsList, String columnName,
String columnType, boolean isMandatory, Integer length) {
final HashMap<String, Object> datatableColumnMap = new HashMap<>();
datatableColumnMap.put("name", columnName);
datatableColumnMap.put("type", columnType);
datatableColumnMap.put("mandatory", isMandatory);
if (length != null) {
datatableColumnMap.put("length", length);
}
datatableColumnsList.add(datatableColumnMap);
return datatableColumnsList;
}
}