Newer
Older
ExcelImport / src / test / com / tesr / services / implementations / ExcelServiceTest.java
package test.com.tesr.services.implementations; 

import com.tesr.services.implementations.ExcelService;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Before; 
import org.junit.After;

import java.util.List;

/** 
* ExcelService Tester. 
* 
* @author <Authors name> 
* @since <pre>Juni 3, 2021</pre> 
* @version 1.0 
*/ 
public class ExcelServiceTest { 

@Before
public void before() throws Exception { 
} 

@After
public void after() throws Exception { 
} 

/** 
* 
* Method: ReadExcelFile(String filename, String sheetname) 
* 
*/ 
@Test
public void testReadExcelFile() throws Exception {
    ExcelService excelService = new ExcelService();
    Assert.assertTrue(excelService.ReadExcelFile("/Users/michel/Downloads/Financial Sample.xlsx", "Sheet1"));
} 

/** 
* 
* Method: SortSheetColumn(int columnToSort, int startRow, boolean wholeTable) 
* 
*/ 
@Test
public void testSortSheetColumn() throws Exception {
    ExcelService excelService = new ExcelService();
    excelService.ReadExcelFile("/Users/michel/Downloads/Financial Sample.xlsx", "Sheet1");
    List<XSSFRow> result = excelService.SortSheetColumn(1, 2);
    Assert.assertNotNull(result);
    Assert.assertTrue(result.get(19).getCell(1).getStringCellValue().equals("Canada"));
    Assert.assertTrue(result.get(141).getCell(1).getStringCellValue().equals("France"));
    Assert.assertTrue(result.get(279).getCell(1).getStringCellValue().equals("Germany"));
    Assert.assertTrue(result.get(279).getCell(4).getNumericCellValue() == 1321);
} 


}