You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/11/28 11:07:36 UTC

[GitHub] [fineract] galovics commented on a diff in pull request #2753: FINERACT-1816: Create client with datatable subentity type

galovics commented on code in PR #2753:
URL: https://github.com/apache/fineract/pull/2753#discussion_r1033407082


##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java:
##########
@@ -263,4 +282,51 @@ public void testClientAddressCreationWorksAfterClientIsCreated() {
         assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
     }
 
+    @Test
+    public void createClientWithDatatable() {
+        // creating datatable for client entity person subentity
+        final HashMap<String, Object> columnMap = new HashMap<>();
+        final List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5).toLowerCase().toLowerCase();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", "PERSON");
+        columnMap.put("multiRow", false);
+        String itsAString = "itsastring";
+        String dateFormat = "dateFormat";
+
+        DatatableHelper.addDatatableColumns(datatableColumnsList, itsAString, "String", true, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        HashMap<String, Object> datatableResponse = datatableHelper.createDatatable(datatabelRequestJsonString, "");
+        final String resourceIdentifier = (String) datatableResponse.get("resourceIdentifier");
+        DatatableHelper.verifyDatatableCreatedOnServer(requestSpec, responseSpec, resourceIdentifier);
+
+        final PostEntityDatatableChecksTemplateResponse entityPersonDatatableChecksResponse = entityDatatableChecksHelper
+                .addEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableName, 100, null);
+        assertNotNull(entityPersonDatatableChecksResponse);

Review Comment:
   Let's check more things from the response body, not just that it's not null.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java:
##########
@@ -263,4 +282,51 @@ public void testClientAddressCreationWorksAfterClientIsCreated() {
         assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
     }
 
+    @Test
+    public void createClientWithDatatable() {
+        // creating datatable for client entity person subentity
+        final HashMap<String, Object> columnMap = new HashMap<>();
+        final List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5).toLowerCase().toLowerCase();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", "PERSON");
+        columnMap.put("multiRow", false);
+        String itsAString = "itsastring";
+        String dateFormat = "dateFormat";
+
+        DatatableHelper.addDatatableColumns(datatableColumnsList, itsAString, "String", true, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        HashMap<String, Object> datatableResponse = datatableHelper.createDatatable(datatabelRequestJsonString, "");
+        final String resourceIdentifier = (String) datatableResponse.get("resourceIdentifier");
+        DatatableHelper.verifyDatatableCreatedOnServer(requestSpec, responseSpec, resourceIdentifier);
+
+        final PostEntityDatatableChecksTemplateResponse entityPersonDatatableChecksResponse = entityDatatableChecksHelper
+                .addEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableName, 100, null);
+        assertNotNull(entityPersonDatatableChecksResponse);
+        LOG.info("entityDatatableChecksResponse : {}", entityPersonDatatableChecksResponse.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", datatableName);
+        datatablesMap.put("data", datatableEntryMap);
+
+        String datatablesJsonString = new Gson().toJson(datatablesMap);
+        LOG.info("map1 : {}", datatablesJsonString);
+
+        PostClientsResponse postClientsResponse = ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpec, "04 March 2011",
+                "1", datatablesMap);
+        assertNotNull(postClientsResponse);

Review Comment:
   Let's check more things from the response body, not just that it's not null.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java:
##########
@@ -263,4 +282,51 @@ public void testClientAddressCreationWorksAfterClientIsCreated() {
         assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
     }
 
+    @Test
+    public void createClientWithDatatable() {
+        // creating datatable for client entity person subentity
+        final HashMap<String, Object> columnMap = new HashMap<>();
+        final List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5).toLowerCase().toLowerCase();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", "PERSON");
+        columnMap.put("multiRow", false);
+        String itsAString = "itsastring";
+        String dateFormat = "dateFormat";
+
+        DatatableHelper.addDatatableColumns(datatableColumnsList, itsAString, "String", true, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        HashMap<String, Object> datatableResponse = datatableHelper.createDatatable(datatabelRequestJsonString, "");
+        final String resourceIdentifier = (String) datatableResponse.get("resourceIdentifier");
+        DatatableHelper.verifyDatatableCreatedOnServer(requestSpec, responseSpec, resourceIdentifier);
+
+        final PostEntityDatatableChecksTemplateResponse entityPersonDatatableChecksResponse = entityDatatableChecksHelper
+                .addEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableName, 100, null);
+        assertNotNull(entityPersonDatatableChecksResponse);
+        LOG.info("entityDatatableChecksResponse : {}", entityPersonDatatableChecksResponse.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", datatableName);
+        datatablesMap.put("data", datatableEntryMap);
+
+        String datatablesJsonString = new Gson().toJson(datatablesMap);
+        LOG.info("map1 : {}", datatablesJsonString);
+
+        PostClientsResponse postClientsResponse = ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpec, "04 March 2011",
+                "1", datatablesMap);
+        assertNotNull(postClientsResponse);
+
+        postClientsResponse = ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpecErr403, "04 March 2011", "1", null);
+
+        entityDatatableChecksHelper.deleteEntityDatatableCheck(entityPersonDatatableChecksResponse.getResourceId().intValue());

Review Comment:
   I think we're missing an assertion after this; that the entity datatable check has been really deleted.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/ClientTest.java:
##########
@@ -263,4 +282,51 @@ public void testClientAddressCreationWorksAfterClientIsCreated() {
         assertThat(addressResponse.getPostalCode()).isEqualTo(postalCode);
     }
 
+    @Test
+    public void createClientWithDatatable() {
+        // creating datatable for client entity person subentity
+        final HashMap<String, Object> columnMap = new HashMap<>();
+        final List<HashMap<String, Object>> datatableColumnsList = new ArrayList<>();
+        final String datatableName = Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_", 5).toLowerCase().toLowerCase();
+        columnMap.put("datatableName", datatableName);
+        columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+        columnMap.put("entitySubType", "PERSON");
+        columnMap.put("multiRow", false);
+        String itsAString = "itsastring";
+        String dateFormat = "dateFormat";
+
+        DatatableHelper.addDatatableColumns(datatableColumnsList, itsAString, "String", true, 10, null);
+        columnMap.put("columns", datatableColumnsList);
+        String datatabelRequestJsonString = new Gson().toJson(columnMap);
+        LOG.info("map : {}", datatabelRequestJsonString);
+
+        HashMap<String, Object> datatableResponse = datatableHelper.createDatatable(datatabelRequestJsonString, "");
+        final String resourceIdentifier = (String) datatableResponse.get("resourceIdentifier");
+        DatatableHelper.verifyDatatableCreatedOnServer(requestSpec, responseSpec, resourceIdentifier);
+
+        final PostEntityDatatableChecksTemplateResponse entityPersonDatatableChecksResponse = entityDatatableChecksHelper
+                .addEntityDatatableCheck(CLIENT_APP_TABLE_NAME, datatableName, 100, null);
+        assertNotNull(entityPersonDatatableChecksResponse);
+        LOG.info("entityDatatableChecksResponse : {}", entityPersonDatatableChecksResponse.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", datatableName);
+        datatablesMap.put("data", datatableEntryMap);
+
+        String datatablesJsonString = new Gson().toJson(datatablesMap);
+        LOG.info("map1 : {}", datatablesJsonString);
+
+        PostClientsResponse postClientsResponse = ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpec, "04 March 2011",
+                "1", datatablesMap);
+        assertNotNull(postClientsResponse);
+
+        postClientsResponse = ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpecErr403, "04 March 2011", "1", null);

Review Comment:
   Let's check the response here.



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org