josehernandezfintecheandomx commented on code in PR #2881:
URL: https://github.com/apache/fineract/pull/2881#discussion_r1071252666


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/DatatableIntegrationTest.java:
##########
@@ -426,6 +430,92 @@ public void validateInsertNullValues() {
         assertEquals(0, updatedDatatableEntryResponse.getChanges().size());
     }
 
+    @Test
+    public void validateCreateAndEditDatatable() {
+        // Creating client
+        final Integer clientId = 
ClientHelper.createClientAsPerson(requestSpec, responseSpec);
+        final Integer randomNumber = Utils.randomNumberGenerator(3);
+
+        // Creating datatable for Client Person
+        final String datatableName = 
Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5);
+        final boolean genericResultSet = true;
+
+        HashMap<String, Object> columnMap = new HashMap<>();
+        List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        columnMap.put("multiRow", false);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, 
"itsANumber", "Number", false, null, null);
+        DatatableHelper.addDatatableColumns(datatableColumnsList, 
"itsAString", "String", false, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        PostDataTablesResponse datatableCreateResponse = 
this.datatableHelper.createDatatable(datatabelRequestJsonString);
+        assertEquals(datatableName, 
datatableCreateResponse.getResourceIdentifier());
+        DatatableHelper.verifyDatatableCreatedOnServer(this.requestSpec, 
this.responseSpec, datatableName);
+
+        // Insert first values
+        String value = Utils.randomStringGenerator("Q", 8);
+        HashMap<String, Object> datatableEntryMap = new HashMap<>();
+        datatableEntryMap.put("itsANumber", randomNumber);
+        datatableEntryMap.put("itsAString", value);
+
+        datatableEntryMap.put("locale", "en");
+        datatableEntryMap.put("dateFormat", "yyyy-MM-dd");
+
+        String datatableEntryRequestJsonString = new 
GsonBuilder().serializeNulls().create().toJson(datatableEntryMap);
+        PostDataTablesAppTableIdResponse datatableEntryResponse = 
this.datatableHelper.addDatatableEntry(datatableName, clientId,
+                genericResultSet, datatableEntryRequestJsonString);
+        assertNotNull(datatableEntryResponse.getResourceId(), "ERROR IN 
CREATING THE ENTITY DATATABLE RECORD");
+
+        // Read the Datatable entry generated with genericResultSet in true 
(default)
+        HashMap<String, Object> items = 
this.datatableHelper.readDatatableEntry(datatableName, clientId, 
genericResultSet, null, "");
+        assertNotNull(items);
+        assertEquals(1, ((List) items.get("data")).size());
+
+        assertEquals(clientId, ((List) ((Map) ((List) 
items.get("data")).get(0)).get("row")).get(0));
+        assertEquals(value, ((List) ((Map) ((List) 
items.get("data")).get(0)).get("row")).get(2));
+
+        // Update DataTable
+        columnMap = new HashMap<>();
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", CLIENT_PERSON_SUBTYPE_NAME);
+        datatableColumnsList = new ArrayList<>();
+        DatatableHelper.addDatatableColumns(datatableColumnsList, "itsAText", 
"Text", false, null, null);
+        columnMap.put("addColumns", datatableColumnsList);
+        datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map to update : {}", datatabelRequestJsonString);
+        PutDataTablesResponse datatableUpdateResponse = 
this.datatableHelper.updateDatatable(datatableName, datatabelRequestJsonString);
+        assertNotNull(datatableUpdateResponse);
+        assertEquals(datatableName, 
datatableUpdateResponse.getResourceIdentifier());
+
+        // Update DataTable Entry after Update DataTable schema

Review Comment:
   Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to