Fixed OfficeImportTest

This commit is contained in:
Petri Tuomola
2020-06-08 07:00:15 +02:00
committed by Michael Vorburger ⛑️
parent cfe5848a02
commit 6eb3873a5b
@@ -30,6 +30,7 @@ import java.io.OutputStream;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; 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.OfficeConstants;
import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants; import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
import org.apache.fineract.integrationtests.common.OfficeHelper; 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.apache.poi.ss.usermodel.Workbook;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OfficeImportHandlerTest { public class OfficeImportHandlerTest {
private final static Logger LOG = LoggerFactory.getLogger(OfficeImportHandlerTest.class);
private ResponseSpecification responseSpec; private ResponseSpecification responseSpec;
private RequestSpecification requestSpec; private RequestSpecification requestSpec;
@@ -60,7 +65,6 @@ public class OfficeImportHandlerTest {
} }
@Test @Test
@Ignore
public void testOfficeImport() throws IOException, InterruptedException, NoSuchFieldException, ParseException { public void testOfficeImport() throws IOException, InterruptedException, NoSuchFieldException, ParseException {
OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec); OfficeHelper officeHelper=new OfficeHelper(requestSpec,responseSpec);
Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy"); Workbook workbook=officeHelper.getOfficeWorkBook("dd MMMM yyyy");
@@ -80,7 +84,7 @@ public class OfficeImportHandlerTest {
"resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office"); "resources"+File.separator+"bulkimport"+File.separator+"importhandler"+File.separator+"office");
if (!directory.exists()) { if (!directory.exists()) {
directory.mkdirs(); directory.mkdirs();
} }
File file= new File(directory+File.separator+"Office.xls"); File file= new File(directory+File.separator+"Office.xls");
OutputStream outputStream=new FileOutputStream(file); OutputStream outputStream=new FileOutputStream(file);
workbook.write(outputStream); workbook.write(outputStream);
@@ -91,7 +95,7 @@ public class OfficeImportHandlerTest {
Assert.assertNotNull(importDocumentId); Assert.assertNotNull(importDocumentId);
// Wait for the creation of output excel // Wait for the creation of output excel
Thread.sleep(3000); Thread.sleep(10000);
//check status column of output excel //check status column of output excel
String location=officeHelper.getOutputTemplateLocation(importDocumentId); String location=officeHelper.getOutputTemplateLocation(importDocumentId);
@@ -99,7 +103,11 @@ public class OfficeImportHandlerTest {
Workbook outputWorkbook=new HSSFWorkbook(fileInputStream); Workbook outputWorkbook=new HSSFWorkbook(fileInputStream);
Sheet officeSheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME); Sheet officeSheet = outputWorkbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row row= officeSheet.getRow(1); 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()); Assert.assertEquals("Imported",row.getCell(OfficeConstants.STATUS_COL).getStringCellValue());
outputWorkbook.close();
} }
} }