Create client with datatable subentity type
This commit is contained in:
committed by
Arnold Gálovics
parent
29b900cccd
commit
804bdc28b9
+1
-1
@@ -97,7 +97,7 @@ public class ClientEntityImportHandlerTest {
|
||||
CodeHelper.retrieveOrCreateCodeValue(25, requestSpec, responseSpec);
|
||||
|
||||
ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
|
||||
Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM yyyy");
|
||||
Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTITY, "dd MMMM yyyy");
|
||||
|
||||
// insert dummy data into client entity sheet
|
||||
Sheet clientEntitySheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class ClientEntityWorkbookPopulatorTest {
|
||||
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
|
||||
|
||||
ClientHelper clientHelper = new ClientHelper(requestSpec, responseSpec);
|
||||
Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM yyyy");
|
||||
Workbook workbook = clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTITY, "dd MMMM yyyy");
|
||||
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
|
||||
Row firstOfficeRow = officeSheet.getRow(1);
|
||||
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found for given OfficeId ");
|
||||
|
||||
+30
-1
@@ -29,6 +29,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -156,6 +157,15 @@ public class ClientHelper extends IntegrationTest {
|
||||
"clientId");
|
||||
}
|
||||
|
||||
public static PostClientsResponse createClientAsPersonWithDatatable(final RequestSpecification requestSpec,
|
||||
final ResponseSpecification responseSpec, final String activationDate, final String officeId,
|
||||
final HashMap<String, Object> datatables) {
|
||||
log.info("---------------------------------CREATING A CLIENT PERSON WITH DATATABLE---------------------------------------------");
|
||||
final String response = Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
|
||||
getTestPersonClientAsJSON(activationDate, officeId, datatables), null);
|
||||
return GSON.fromJson(response, PostClientsResponse.class);
|
||||
}
|
||||
|
||||
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
|
||||
}
|
||||
@@ -281,6 +291,25 @@ public class ClientHelper extends IntegrationTest {
|
||||
return GSON.toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestPersonClientAsJSON(final String dateOfJoining, final String officeId,
|
||||
final HashMap<String, Object> datatables) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("officeId", officeId);
|
||||
map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
|
||||
map.put("externalId", randomIDGenerator("ID_", 7));
|
||||
map.put("dateFormat", Utils.DATE_FORMAT);
|
||||
map.put("locale", "en");
|
||||
map.put("active", "true");
|
||||
map.put("activationDate", dateOfJoining);
|
||||
map.put("legalFormId", 1);
|
||||
if (datatables != null) {
|
||||
map.put("datatables", Arrays.asList(datatables));
|
||||
}
|
||||
|
||||
log.info("map : {}", map);
|
||||
return GSON.toJson(map);
|
||||
}
|
||||
|
||||
public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId,
|
||||
final Integer soleProprietorCodeValueId) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
@@ -665,7 +694,7 @@ public class ClientHelper extends IntegrationTest {
|
||||
public String importClientEntityTemplate(File file) {
|
||||
String locale = "en";
|
||||
String dateFormat = "dd MMMM yyyy";
|
||||
String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString();
|
||||
String legalFormType = GlobalEntityType.CLIENTS_ENTITY.toString();
|
||||
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
|
||||
return Utils.performServerTemplatePost(requestSpec, responseSpec, CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
|
||||
legalFormType, file, locale, dateFormat);
|
||||
|
||||
@@ -210,6 +210,7 @@ public final class Utils {
|
||||
|
||||
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
||||
LOG.info("JSON {}", jsonBodyToSend);
|
||||
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
|
||||
.andReturn().asString();
|
||||
if (jsonAttributeToGetBack == null) {
|
||||
|
||||
+12
@@ -22,6 +22,8 @@ import com.google.gson.Gson;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
import io.restassured.specification.ResponseSpecification;
|
||||
import java.util.HashMap;
|
||||
import org.apache.fineract.client.models.PostEntityDatatableChecksTemplateResponse;
|
||||
import org.apache.fineract.client.util.JSON;
|
||||
import org.apache.fineract.integrationtests.common.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -34,6 +36,8 @@ public class EntityDatatableChecksHelper {
|
||||
|
||||
private static final String DATATABLE_CHECK_URL = "/fineract-provider/api/v1/entityDatatableChecks";
|
||||
|
||||
private static final Gson GSON = new JSON().getGson();
|
||||
|
||||
public EntityDatatableChecksHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||
this.requestSpec = requestSpec;
|
||||
this.responseSpec = responseSpec;
|
||||
@@ -45,6 +49,14 @@ public class EntityDatatableChecksHelper {
|
||||
getTestEdcAsJSON(apptableName, datatableName, status, productId), "resourceId");
|
||||
}
|
||||
|
||||
public PostEntityDatatableChecksTemplateResponse addEntityDatatableCheck(final String apptableName, final String datatableName,
|
||||
final int status, final Integer productId) {
|
||||
final String response = Utils.performServerPost(this.requestSpec, this.responseSpec,
|
||||
DATATABLE_CHECK_URL + "?" + Utils.TENANT_IDENTIFIER, getTestEdcAsJSON(apptableName, datatableName, status, productId),
|
||||
null);
|
||||
return GSON.fromJson(response, PostEntityDatatableChecksTemplateResponse.class);
|
||||
}
|
||||
|
||||
public Integer deleteEntityDatatableCheck(final Integer entityDatatableCheckId) {
|
||||
return Utils.performServerDelete(requestSpec, responseSpec,
|
||||
DATATABLE_CHECK_URL + "/" + entityDatatableCheckId + "?" + Utils.TENANT_IDENTIFIER, "resourceId");
|
||||
|
||||
+74
@@ -21,6 +21,7 @@ package org.apache.fineract.integrationtests.common.organisation;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.restassured.builder.RequestSpecBuilder;
|
||||
import io.restassured.builder.ResponseSpecBuilder;
|
||||
import io.restassured.http.ContentType;
|
||||
@@ -30,6 +31,8 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import org.apache.fineract.client.models.PostClientsResponse;
|
||||
import org.apache.fineract.client.models.PostEntityDatatableChecksTemplateResponse;
|
||||
import org.apache.fineract.integrationtests.common.ClientHelper;
|
||||
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
||||
import org.apache.fineract.integrationtests.common.CommonConstants;
|
||||
@@ -549,4 +552,75 @@ public class EntityDatatableChecksIntegrationTest {
|
||||
datatablesListMap.add(datatableMap);
|
||||
return datatablesListMap;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createClientWithDatatableUsingEntitySubtype() {
|
||||
// creating datatable for client entity person subentity
|
||||
HashMap<String, Object> columnMap = new HashMap<>();
|
||||
final List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
|
||||
final String datatableNamePerson = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_person_", 5).toLowerCase().toLowerCase();
|
||||
final String datatableNameEntity = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_entity_", 5).toLowerCase().toLowerCase();
|
||||
|
||||
String itsAString = "itsastring";
|
||||
DatatableHelper.addDatatableColumns(datatableColumnsList, itsAString, "String", true, 10, null);
|
||||
|
||||
// Person Subtype
|
||||
columnMap.put("datatableName", datatableNamePerson);
|
||||
columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
|
||||
columnMap.put("entitySubType", "PERSON");
|
||||
columnMap.put("multiRow", false);
|
||||
String dateFormat = "dateFormat";
|
||||
|
||||
columnMap.put("columns", datatableColumnsList);
|
||||
String datatabelRequestJsonString = new Gson().toJson(columnMap);
|
||||
LOG.info("map : {}", datatabelRequestJsonString);
|
||||
|
||||
datatableHelper.createDatatable(datatabelRequestJsonString, "");
|
||||
|
||||
PostEntityDatatableChecksTemplateResponse entityDatatableChecksResponse = entityDatatableChecksHelper
|
||||
.addEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableNamePerson, 100, null);
|
||||
assertNotNull(entityDatatableChecksResponse);
|
||||
final Long personDatatableCheck = entityDatatableChecksResponse.getResourceId();
|
||||
LOG.info("entityDatatableChecksResponse Person: {}", entityDatatableChecksResponse.getResourceId());
|
||||
|
||||
// Entity Subtype
|
||||
columnMap = new HashMap<>();
|
||||
columnMap.put("datatableName", datatableNameEntity);
|
||||
columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
|
||||
columnMap.put("entitySubType", "ENTITY");
|
||||
columnMap.put("multiRow", false);
|
||||
|
||||
columnMap.put("columns", datatableColumnsList);
|
||||
datatabelRequestJsonString = new Gson().toJson(columnMap);
|
||||
LOG.info("map : {}", datatabelRequestJsonString);
|
||||
|
||||
datatableHelper.createDatatable(datatabelRequestJsonString, "");
|
||||
|
||||
entityDatatableChecksResponse = entityDatatableChecksHelper.addEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableNameEntity, 100,
|
||||
null);
|
||||
assertNotNull(entityDatatableChecksResponse);
|
||||
final Long entityDatatableCheck = entityDatatableChecksResponse.getResourceId();
|
||||
LOG.info("entityDatatableChecksResponse Entity: {}", entityDatatableChecksResponse.getResourceId());
|
||||
|
||||
final HashMap<String, Object> datatableEntryMap = new HashMap<>();
|
||||
datatableEntryMap.put(itsAString, Utils.randomStringGenerator("", 8));
|
||||
datatableEntryMap.put("locale", "en");
|
||||
|
||||
final HashMap<String, Object> datatablesMap = new HashMap<>();
|
||||
datatablesMap.put("registeredTableName", datatableNamePerson);
|
||||
datatablesMap.put("data", datatableEntryMap);
|
||||
|
||||
String datatablesJsonString = new Gson().toJson(datatablesMap);
|
||||
LOG.info("map : {}", datatablesJsonString);
|
||||
|
||||
PostClientsResponse postClientsResponse = ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpec, "04 March 2011",
|
||||
"1", datatablesMap);
|
||||
assertNotNull(postClientsResponse);
|
||||
assertNotNull(postClientsResponse.getResourceId());
|
||||
|
||||
// Remove the Entity Datatable checks for others tests
|
||||
entityDatatableChecksHelper.deleteEntityDatatableCheck(personDatatableCheck.intValue());
|
||||
entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheck.intValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user