title: How to test the method that reads the data from the excel file in java?
body: <p><a href="https://i.stack.imgur.com/3vgd1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3vgd1.png" alt="enter image description here"></a>
  The above picture shows the excel file containing the Facebook data.</p>
  
  <p>The class <code>FacebookDataExtraction</code> reads the data from the Excel file and stores the data as list of row objects as shown in the code.
  I have made use of the config.properties file to get the file path. The contents of config.properties file are: <code>FILE_NAME=D:/Refreshed_data_daily/all_hue_posts_in_excel.xlsx.</code></p>
  
  <pre><code>public class FacebookDataExtraction {
  
  //private static final String FILE_NAME="D:/Refreshed_data_daily/all_hue_posts_in_excel.xlsx";
  private static final String SHEET_NAME="nextv54plus_actions";
  XSSFWorkbook workbook;
  
      public static void main(String[] args){
  
          FacebookDataExtraction obj= new FacebookDataExtraction();
          List&lt;FacebookFields&gt; displayList= new ArrayList&lt;FacebookFields&gt;();
          displayList=obj.readFromExcel();
          System.out.println("The Size of the list is:"+ displayList.size());
      }
  
      public List&lt;FacebookFields&gt; readFromExcel() {
          List&lt;FacebookFields&gt; fbList= new ArrayList&lt;FacebookFields&gt;();
          try
          {
              ReadPropertyFile data= new ReadPropertyFile("config.properties");
              FileInputStream fin= new FileInputStream(data.getPropertyFor("FILE_NAME"));
              workbook= new XSSFWorkbook(fin);
              int sheetIndex=0;
              for (Sheet sheet : workbook) {
                  readSheet(sheet,sheetIndex ++, fbList);}
  
          }catch(FileNotFoundException e){
              e.printStackTrace();
          }
          catch(IOException e){
              e.printStackTrace();
          }
          return fbList;
      }
  
      private void readSheet(Sheet sheet, int sheetIndex , List&lt;FacebookFields&gt; fbList) {
  
          if(SHEET_NAME.equals(sheet.getSheetName())){
              workbook.removeSheetAt(sheetIndex);
              return;
          }
          for (Row row : sheet){
              if (row.getRowNum() &gt; 0)
                  fbList.add(readRow(row));}
  
      }
  
      private FacebookFields readRow(Row row) {
  
          FacebookFields record= new FacebookFields();
          for (Cell cell : row) {
              switch (cell.getColumnIndex()) {
              case 0: record.setName(cell.getStringCellValue()); 
              break; 
              case 1: record.setId(cell.getStringCellValue()); 
              break; 
              case 2: record.setDate(cell.getStringCellValue());
              break; 
              case 3: record.setMessage(cell.getStringCellValue());
              break; 
              case 4: record.setType(cell.getStringCellValue());
              break; 
              case 5: record.setPage(cell.getStringCellValue());
              break; 
              case 6: record.setLikeCount(String.valueOf(cell.getNumericCellValue()));
              break; 
              case 7: record.setCommentCount(String.valueOf(cell.getNumericCellValue())); 
              break; 
              case 8: record.setShareCount(String.valueOf(cell.getNumericCellValue())); 
              break; 
              }
          }
  
          return record;
      }
  
      public boolean containsData() {  
  
          List&lt;FacebookFields&gt; checkList= readFromExcel();    
          return !checkList.isEmpty() ;
      }
  
      }
  </code></pre>
  
  <p>The <code>FacebookFields</code> class(not shown here) contains the set methods for the data extracted!
  How to I write a test case for method <code>readRow()</code> or how to test whether each field of the column contains data?</p>