CompetitiveIntelligenceReportParser implements Callable<CompetitiveIntelligenceReports> { @Override public CompetitiveIntelligenceReports call() throws Exception { final CompetitiveIntelligenceReports reports = new CompetitiveIntelligenceReports(); final FlatFileItemReader<CompetitiveIntelligenceReports> items = CompetitiveIntelligenceReportParserMapper.newItemReader( cirReportCsv, reports); try { items.open(new ExecutionContext()); CompetitiveIntelligenceReports item = null; do { item = items.read(); } while (item != null); } finally { items.close(); } return reports; } CompetitiveIntelligenceReportParser(final Resource cirReportCsv); @Override CompetitiveIntelligenceReports call();  }
@Test public void testParse() throws Exception { final CompetitiveIntelligenceReportParser parser = new CompetitiveIntelligenceReportParser( new ClassPathResource("/" + getClass().getPackage().getName().replace(".", "/") + "/CIR_Y19.csv")); final CompetitiveIntelligenceReports reports = parser.call(); Assertions.assertThat(reports.getFirstYear()).isEqualTo(10); Assertions.assertThat(reports.getLastYear()).isEqualTo(19); for (final CompanyRegion region : CompanyRegion.values()) { for (int i = reports.getFirstYear(); i <= reports.getLastYear(); i++) { try { Assertions.assertThat(reports.getAvg(i, region).isHasValues()).isTrue(); Assertions.assertThat(reports.getForCompany(i, region, CompanyLetter.A).isHasValues()).isTrue(); Assertions.assertThat(reports.getForCompany(i, region, CompanyLetter.L).isHasValues()).isFalse(); } catch (final Throwable t) { throw new RuntimeException("year=" + i + ", region=" + region, t); } } } }