1+ package model ;
2+
3+ import exceptions .ExtensionNotValidException ;
4+ import exceptions .OpenWorkbookException ;
5+ import exceptions .SheetNotFoundException ;
6+ import org .junit .jupiter .api .Assertions ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ import java .io .File ;
10+ import java .io .IOException ;
11+ import java .util .List ;
12+
13+ class ExcelRowTest {
14+
15+ private final File excelFile = new File ("./src/test/resources/employee.xlsx" );
16+
17+ @ Test
18+ void getCells () throws OpenWorkbookException , ExtensionNotValidException , IOException , SheetNotFoundException {
19+ ExcelWorkbook excelWorkbook = ExcelWorkbook .open (excelFile );
20+ ExcelSheet excelSheet = excelWorkbook .getSheet ("Office" );
21+ ExcelRow excelRow = excelSheet .getRows ().get (0 );
22+ List <ExcelCell > excelCells = excelRow .getCells ();
23+ Assertions .assertEquals ("CITY" , excelCells .get (0 ).getCell ().getStringCellValue ());
24+ Assertions .assertEquals ("PROVINCE" , excelCells .get (1 ).getCell ().getStringCellValue ());
25+ Assertions .assertEquals ("NUMBER OF STATIONS" , excelCells .get (2 ).getCell ().getStringCellValue ());
26+
27+ }
28+
29+ @ Test
30+ void getSheet () throws OpenWorkbookException , ExtensionNotValidException , IOException , SheetNotFoundException {
31+ ExcelWorkbook excelWorkbook = ExcelWorkbook .open (excelFile );
32+ ExcelSheet excelSheet = excelWorkbook .getSheet ();
33+ ExcelRow excelRow = excelSheet .getRows ().get (0 );
34+ ExcelSheet excelSheet1 = excelRow .getSheet ();
35+ Assertions .assertEquals (excelSheet , excelSheet1 );
36+ }
37+ }
0 commit comments