### Question:
ReaderUtil { public static void process(String path, String sheetName, ZeroCellReader reader) { if (path == null || path.trim().isEmpty()) { throw new IllegalArgumentException("'path' must be given"); } File file = new File(path); if (file.exists() && file.isDirectory()) { throw new IllegalArgumentException("path must not be a directory"); } try (OPCPackage opcPackage = OPCPackage.open(file.getAbsolutePath(), PackageAccess.READ)) { process(opcPackage, sheetName, reader); } catch(InvalidFormatException | EmptyFileException | NotOfficeXmlFileException ife) { throw new ZeroCellException(ERROR_NOT_OPENXML); } catch (IOException ioe) { throw new ZeroCellException("Failed to process file", ioe); } }  static void process(String path, String sheetName, ZeroCellReader reader); static void process(File file, String sheetName, ZeroCellReader reader); static void process(InputStream is, String sheetName, ZeroCellReader reader); static final String ERROR_NOT_OPENXML; }### Answer:
@Test public void testCanProcessFilePath() { final EntityHandler<Person> entityHandler = new EntityHandler<Person>( Person.class, false, 0, 0 ); ReaderUtil.process( "src/test/resources/test_people.xlsx", entityHandler.getSheetName(), entityHandler.getEntitySheetHandler() ); List<Person> people = entityHandler.readAsList(); assertNotNull(people); assertFalse(people.isEmpty()); assertEquals(5, people.size()); Person zikani = people.get(0); assertEquals(1, zikani.getRowNumber()); assertEquals("Zikani", zikani.getFirstName()); }
@Test public void testCanProcessFile() { final EntityHandler<Person> entityHandler = new EntityHandler<Person>( Person.class, false, 0, 0 ); ReaderUtil.process( new File("src/test/resources/test_people.xlsx"), entityHandler.getSheetName(), entityHandler.getEntitySheetHandler() ); List<Person> people = entityHandler.readAsList(); assertNotNull(people); assertFalse(people.isEmpty()); assertEquals(5, people.size()); Person zikani = people.get(0); assertEquals(1, zikani.getRowNumber()); assertEquals("Zikani", zikani.getFirstName()); }
@Test public void testFailToProcessFirstSheet() { final EntityHandler<Person> entityHandler = new EntityHandler<Person>( Person.class, false, 0, 0 ); try { ReaderUtil.process( new File("src/test/resources/test_people_with_offset_sheet.xlsx"), EntityHandler.DEFAULT_SHEET, entityHandler.getEntitySheetHandler() ); fail("Somehow read the correct sheet."); } catch(ZeroCellException e) { assertEquals("Expected Column 'ID' but found 'This sheet is the first but not the intended sheet'", e.getMessage()); } }
@Test public void testCanProcessInputStream() throws IOException { final EntityHandler<Person> entityHandler = new EntityHandler<Person>( Person.class, false, 0, 0 ); ReaderUtil.process( Files.newInputStream( Paths.get("src", "test", "resources", "test_people.xlsx")), entityHandler.getSheetName(), entityHandler.getEntitySheetHandler() ); List<Person> people = entityHandler.readAsList(); assertNotNull(people); assertFalse(people.isEmpty()); assertEquals(5, people.size()); Person zikani = people.get(0); assertEquals(1, zikani.getRowNumber()); assertEquals("Zikani", zikani.getFirstName()); }