You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by vo...@apache.org on 2020/06/08 05:00:25 UTC

[fineract] branch develop updated (cfe5848 -> b31e6c2)

This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git.


    from cfe5848  FINERACT-822 enable OperatorPrecedence error
     new 6eb3873  Fixed OfficeImportTest
     new b31e6c2  FINERACT-1019: Fix failing import integration tests

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../client/ClientEntityImportHandlerTest.java      | 34 ++++++------
 .../office/OfficeImportHandlerTest.java            | 15 ++++--
 .../savings/SavingsImportHandlerTest.java          | 63 ++++++++++++++++------
 3 files changed, 76 insertions(+), 36 deletions(-)


[fineract] 01/02: Fixed OfficeImportTest

Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit 6eb3873a5bf03d99c8661cfde0bc02408b4bd0ff
Author: Petri Tuomola <pe...@tuomola.org>
AuthorDate: Thu Jun 4 05:27:23 2020 +0300

    Fixed OfficeImportTest
---
 .../importhandler/office/OfficeImportHandlerTest.java  | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
index d96d764..a0d3c49 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
@@ -30,6 +30,7 @@ import java.io.OutputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants;
 import org.apache.fineract.infrastructure.bulkimport.constants.OfficeConstants;
 import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.integrationtests.common.OfficeHelper;
@@ -40,10 +41,14 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class OfficeImportHandlerTest {
+    
+    private final static Logger LOG = LoggerFactory.getLogger(OfficeImportHandlerTest.class);
+
     private ResponseSpecification responseSpec;
     private RequestSpecification requestSpec;
 
@@ -60,7 +65,6 @@ public class OfficeImportHandlerTest {
     }
 
     @Test
-    @Ignore
     public void testOfficeImport() throws IOException, InterruptedException, NoSuchFieldException, ParseException {
         OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
         Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy");
@@ -80,7 +84,7 @@ public class OfficeImportHandlerTest {
                 "resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office");
         if (!directory.exists()) {
             directory.mkdirs();
-        }
+        } 
         File file= new File(directory+File.separator+"Office.xls");
         OutputStream outputStream=new FileOutputStream(file);
         workbook.write(outputStream);
@@ -91,7 +95,7 @@ public class OfficeImportHandlerTest {
         Assert.assertNotNull(importDocumentId);
 
         // Wait for the creation of output excel
-        Thread.sleep(3000);
+        Thread.sleep(10000);
 
         //check  status column of output excel
         String location=officeHelper.getOutputTemplateLocation(importDocumentId);
@@ -99,7 +103,11 @@ public class OfficeImportHandlerTest {
         Workbook outputWorkbook=new HSSFWorkbook(fileInputStream);
         Sheet officeSheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
         Row row= officeSheet.getRow(1);
+        
+        LOG.info("Output location: {}", location);
+        LOG.info("Failure reason column: {}", row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
+        
         Assert.assertEquals("Imported",row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
-
+        outputWorkbook.close();
     }
 }


[fineract] 02/02: FINERACT-1019: Fix failing import integration tests

Posted by vo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit b31e6c2881c59f49ec04c8a11a50acffddf3339a
Author: Petri Tuomola <pe...@tuomola.org>
AuthorDate: Thu Jun 4 06:09:30 2020 +0300

    FINERACT-1019: Fix failing import integration tests
---
 .../client/ClientEntityImportHandlerTest.java      | 34 ++++++------
 .../office/OfficeImportHandlerTest.java            |  9 ++--
 .../savings/SavingsImportHandlerTest.java          | 63 ++++++++++++++++------
 3 files changed, 69 insertions(+), 37 deletions(-)

diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
index 2033469..f1d055e 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
@@ -47,10 +47,13 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ClientEntityImportHandlerTest {
+    private final static Logger LOG = LoggerFactory.getLogger(ClientEntityImportHandlerTest.class);
+
     private ResponseSpecification responseSpec;
     private RequestSpecification requestSpec;
 
@@ -63,36 +66,33 @@ public class ClientEntityImportHandlerTest {
     }
 
     @Test
-    @Ignore
     public void testClientImport() throws InterruptedException, IOException, ParseException {
 
         //in order to populate helper sheets
-        StaffHelper staffHelper=new StaffHelper();
         requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
-        Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
+        Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec,responseSpec);
         Assert.assertNotNull("Could not create staff",outcome_staff_creation);
 
         //in order to populate helper sheets
-        OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
+        OfficeHelper officeHelper = new OfficeHelper(requestSpec,responseSpec);
         Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
         Assert.assertNotNull("Could not create office" ,outcome_office_creation);
 
         //in order to populate helper columns in client entity sheet
-        CodeHelper codeHelper=new CodeHelper();
         //create constitution
-        codeHelper.retrieveOrCreateCodeValue(24,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(24,requestSpec,responseSpec);
         //create client classification
-        codeHelper.retrieveOrCreateCodeValue(17,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(17,requestSpec,responseSpec);
         //create client types
-        codeHelper.retrieveOrCreateCodeValue(16,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(16,requestSpec,responseSpec);
         //create Address types
-        codeHelper.retrieveOrCreateCodeValue(29,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(29,requestSpec,responseSpec);
         //create State
-        codeHelper.retrieveOrCreateCodeValue(27,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(27,requestSpec,responseSpec);
         //create Country
-        codeHelper.retrieveOrCreateCodeValue(28,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(28,requestSpec,responseSpec);
         //create Main business line
-        codeHelper.retrieveOrCreateCodeValue(25,requestSpec,responseSpec);
+        CodeHelper.retrieveOrCreateCodeValue(25,requestSpec,responseSpec);
 
         ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
         Workbook workbook=clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY,"dd MMMM yyyy");
@@ -134,7 +134,7 @@ public class ClientEntityImportHandlerTest {
         Assert.assertNotNull(importDocumentId);
 
         //Wait for the creation of output excel
-        Thread.sleep(3000);
+        Thread.sleep(10000);
 
         //check status column of output excel
         String location=clientHelper.getOutputTemplateLocation(importDocumentId);
@@ -142,7 +142,11 @@ public class ClientEntityImportHandlerTest {
         Workbook outputWorkbook=new HSSFWorkbook(fileInputStream);
         Sheet outputClientEntitySheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
         Row row= outputClientEntitySheet.getRow(1);
-        Assert.assertEquals("Imported",row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue());
 
+        LOG.info("Output location: {}", location);
+        LOG.info("Failure reason column: {}", row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue());
+
+        Assert.assertEquals("Imported",row.getCell(ClientEntityConstants.STATUS_COL).getStringCellValue());
+        outputWorkbook.close();
     }
 }
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
index a0d3c49..421af9c 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/office/OfficeImportHandlerTest.java
@@ -30,7 +30,6 @@ import java.io.OutputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import org.apache.fineract.infrastructure.bulkimport.constants.LoanConstants;
 import org.apache.fineract.infrastructure.bulkimport.constants.OfficeConstants;
 import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.integrationtests.common.OfficeHelper;
@@ -46,7 +45,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class OfficeImportHandlerTest {
-    
+
     private final static Logger LOG = LoggerFactory.getLogger(OfficeImportHandlerTest.class);
 
     private ResponseSpecification responseSpec;
@@ -84,7 +83,7 @@ public class OfficeImportHandlerTest {
                 "resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office");
         if (!directory.exists()) {
             directory.mkdirs();
-        } 
+        }
         File file= new File(directory+File.separator+"Office.xls");
         OutputStream outputStream=new FileOutputStream(file);
         workbook.write(outputStream);
@@ -103,10 +102,10 @@ public class OfficeImportHandlerTest {
         Workbook outputWorkbook=new HSSFWorkbook(fileInputStream);
         Sheet officeSheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
         Row row= officeSheet.getRow(1);
-        
+
         LOG.info("Output location: {}", location);
         LOG.info("Failure reason column: {}", row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
-        
+
         Assert.assertEquals("Imported",row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
         outputWorkbook.close();
     }
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
index ae2b2e0..7ee4417 100644
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/bulkimport/importhandler/savings/SavingsImportHandlerTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.integrationtests.bulkimport.importhandler.savings;
 
+import com.google.gson.Gson;
 import io.restassured.builder.RequestSpecBuilder;
 import io.restassured.builder.ResponseSpecBuilder;
 import io.restassured.http.ContentType;
@@ -31,12 +32,14 @@ import java.io.OutputStream;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import org.apache.fineract.infrastructure.bulkimport.constants.SavingsConstants;
 import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
-import org.apache.fineract.integrationtests.common.ClientHelper;
 import org.apache.fineract.integrationtests.common.GroupHelper;
+import org.apache.fineract.integrationtests.common.OfficeDomain;
 import org.apache.fineract.integrationtests.common.OfficeHelper;
 import org.apache.fineract.integrationtests.common.Utils;
 import org.apache.fineract.integrationtests.common.organisation.StaffHelper;
@@ -48,13 +51,20 @@ import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SavingsImportHandlerTest {
+
+    private final static Logger LOG = LoggerFactory.getLogger(SavingsImportHandlerTest.class);
+
     private ResponseSpecification responseSpec;
     private RequestSpecification requestSpec;
 
+    private static final String CREATE_CLIENT_URL = "/fineract-provider/api/v1/clients?" + Utils.TENANT_IDENTIFIER;
+    public static final String DATE_FORMAT = "dd MMMM yyyy";
+
     @Before
     public void setup() {
         Utils.initializeRESTAssured();
@@ -64,7 +74,6 @@ public class SavingsImportHandlerTest {
     }
 
     @Test
-    @Ignore
     public void testSavingsImport() throws InterruptedException, IOException, ParseException {
 
         requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
@@ -73,24 +82,41 @@ public class SavingsImportHandlerTest {
         Integer outcome_office_creation=officeHelper.createOffice("02 May 2000");
         Assert.assertNotNull("Could not create office" ,outcome_office_creation);
 
-        //in order to populate helper sheets
-        ClientHelper clientHelper=new ClientHelper(requestSpec,responseSpec);
-        Integer outcome_client_creation=clientHelper.createClient(requestSpec,responseSpec);
+        OfficeDomain office = officeHelper.retrieveOfficeByID(outcome_office_creation);
+        Assert.assertNotNull("Could not retrieve created office", office);
+
+        String firstName = Utils.randomNameGenerator("Client_FirstName_", 5);
+        String lastName = Utils.randomNameGenerator("Client_LastName_", 4);
+        String externalId = Utils.randomStringGenerator("ID_", 7, "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+
+        final HashMap<String, String> clientMap = new HashMap<>();
+        clientMap.put("officeId", outcome_office_creation.toString());
+        clientMap.put("firstname", firstName);
+        clientMap.put("lastname", lastName);
+        clientMap.put("externalId", externalId);
+        clientMap.put("dateFormat", DATE_FORMAT);
+        clientMap.put("locale", "en");
+        clientMap.put("active", "true");
+        clientMap.put("activationDate", "04 March 2011");
+
+        Integer outcome_client_creation= Utils.performServerPost(requestSpec, responseSpec, CREATE_CLIENT_URL,
+                new Gson().toJson(clientMap), "clientId");
         Assert.assertNotNull("Could not create client" ,outcome_client_creation);
 
         //in order to populate helper sheets
-        GroupHelper groupHelper=new GroupHelper(requestSpec,responseSpec);
-        Integer outcome_group_creation=groupHelper.createGroup(requestSpec,responseSpec,true);
+        Integer outcome_group_creation=GroupHelper.createGroup(requestSpec,responseSpec,true);
         Assert.assertNotNull("Could not create group" ,outcome_group_creation);
 
         //in order to populate helper sheets
-        StaffHelper staffHelper=new StaffHelper();
-        Integer outcome_staff_creation =staffHelper.createStaff(requestSpec,responseSpec);
+        Integer outcome_staff_creation =StaffHelper.createStaff(requestSpec,responseSpec);
         Assert.assertNotNull("Could not create staff",outcome_staff_creation);
 
-        SavingsProductHelper savingsProductHelper=new SavingsProductHelper();
+        Map<String, Object> staffMap = StaffHelper.getStaff(requestSpec, responseSpec, outcome_staff_creation);
+        Assert.assertNotNull("Could not retrieve created staff", staffMap);
+
+        SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
         String jsonSavingsProduct=savingsProductHelper.build();
-        Integer outcome_sp_creaction=savingsProductHelper.createSavingsProduct(jsonSavingsProduct,requestSpec,responseSpec);
+        Integer outcome_sp_creaction=SavingsProductHelper.createSavingsProduct(jsonSavingsProduct,requestSpec,responseSpec);
         Assert.assertNotNull("Could not create Savings product",outcome_sp_creaction);
 
         SavingsAccountHelper savingsAccountHelper=new SavingsAccountHelper(requestSpec,responseSpec);
@@ -99,14 +125,12 @@ public class SavingsImportHandlerTest {
         //insert dummy data into Savings sheet
         Sheet savingsSheet = workbook.getSheet(TemplatePopulateImportConstants.SAVINGS_ACCOUNTS_SHEET_NAME);
         Row firstSavingsRow=savingsSheet.getRow(1);
-        Sheet officeSheet=workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
-        firstSavingsRow.createCell(SavingsConstants.OFFICE_NAME_COL).setCellValue(officeSheet.getRow(1).getCell(1).getStringCellValue());
+        firstSavingsRow.createCell(SavingsConstants.OFFICE_NAME_COL).setCellValue(office.getName());
         firstSavingsRow.createCell(SavingsConstants.SAVINGS_TYPE_COL).setCellValue("Individual");
-        firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL).setCellValue(savingsSheet.getRow(1).getCell(SavingsConstants.LOOKUP_CLIENT_NAME_COL).getStringCellValue());
+        firstSavingsRow.createCell(SavingsConstants.CLIENT_NAME_COL).setCellValue(firstName + " " + lastName + "(" + outcome_client_creation + ")");
         Sheet savingsProductSheet=workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
         firstSavingsRow.createCell(SavingsConstants.PRODUCT_COL).setCellValue(savingsProductSheet.getRow(1).getCell(1).getStringCellValue());
-        Sheet staffSheet=workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
-        firstSavingsRow.createCell(SavingsConstants.FIELD_OFFICER_NAME_COL).setCellValue(staffSheet.getRow(1).getCell(1).getStringCellValue());
+        firstSavingsRow.createCell(SavingsConstants.FIELD_OFFICER_NAME_COL).setCellValue((String) staffMap.get("displayName"));
         SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd MMMM yyyy");
         Date date=simpleDateFormat.parse("13 May 2017");
         firstSavingsRow.createCell(SavingsConstants.SUBMITTED_ON_DATE_COL).setCellValue(date);
@@ -151,6 +175,11 @@ public class SavingsImportHandlerTest {
         Workbook Outputworkbook=new HSSFWorkbook(fileInputStream);
         Sheet OutputSavingsSheet = Outputworkbook.getSheet(TemplatePopulateImportConstants.SAVINGS_ACCOUNTS_SHEET_NAME);
         Row row= OutputSavingsSheet.getRow(1);
+
+        LOG.info("Output location: {}", location);
+        LOG.info("Failure reason column: {}", row.getCell(SavingsConstants.STATUS_COL).getStringCellValue());
+
         Assert.assertEquals("Imported",row.getCell(SavingsConstants.STATUS_COL).getStringCellValue());
+        Outputworkbook.close();
     }
 }