ExcelFileImportDefault implements ExcelFileImport { @Override public ImportResponse readWorkbook() throws Exception { final long startTime = System.nanoTime(); logger.warn(">>>>>>>>>>>>>>> import started >>>>>>>>>>>>>>>"); final List<String[]> rows = xExcelFileReader.readRows(1000); xExcelFileReader.close(); normalizeRows(rows); ExcelSheetImport excelSheetImport = new ExcelSheetImportDefault(this.applicationContext, rows, this.importBean); final ImportResponse importResponse = excelSheetImport.readSheet(clazz); final long endTime = System.nanoTime(); final double duration = (endTime - startTime) / 1000000000.0; logger.warn(">>>>>>>>>>>>>>> import ended | duration: " + duration + " >>>>>>>>>"); return importResponse; } ExcelFileImportDefault(final ApplicationContext applicationContext, final InputStream is,
                                  final Class clazz, final ImportBean importBean); @Override ImportResponse readWorkbook();  }
@Test public void readWorkbook() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final ExcelFileImport excelFileImport = new ExcelFileImportDefault(new MyApplicationContext(), new FileInputStream(classLoader.getResource("file-import.xlsx").getFile()), TestBuyer.class, new ImportBean(new Category())); final ImportResponse importResponse = excelFileImport.readWorkbook(); TestBuyer testBuyer = (TestBuyer) importResponse.getObjects().get(0); Assert.assertEquals("check number of objects", 2, importResponse.getObjects().size()); Assert.assertEquals("check buyer name", "buyer 1", testBuyer.getName()); Assert.assertEquals("check organization name", "organization 1", testBuyer.getOrg().getName()); Assert.assertEquals("check address", "Street 1", testBuyer.getOrg().getAddress().getStreet()); Assert.assertEquals("check address", "Romania", testBuyer.getOrg().getAddress().getCountry()); }