public void testIterator() throws Exception { IteratorItemReader<String> reader = new IteratorItemReader<>(Arrays.asList(new String[] { "a", "b", "c" }).iterator()); assertEquals("a", reader.read()); assertEquals("b", reader.read()); assertEquals("c", reader.read()); assertEquals(null, reader.read()); }
public void testIterable() throws Exception { IteratorItemReader<String> reader = new IteratorItemReader<>(Arrays.asList(new String[]{"a", "b", "c"})); assertEquals("a", reader.read()); assertEquals("b", reader.read()); assertEquals("c", reader.read()); assertEquals(null, reader.read()); }
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { if (executionContext.containsKey(keyName)) { Map<Sens, BatchExcelRow> map = (Map) executionContext.get(keyName); delegate = new IteratorItemReader<BatchExcelRow>(map.values()); } else { throw new IllegalStateException("Context should contain a value with this key : '" + keyName + "'"); } }
@BeforeStep public void beforeStep(StepExecution stepExecution) { List<LineStop> result = new ArrayList<>(); Language lang = Language.valueOf(language.toUpperCase(Locale.US)); LOGGER.debug("Searching delays for date={}", date); if (date != null) { result = service.searchDelaysBetween(date, new Station(stationA, lang), new Station(stationB, lang), threshold); } Collections.sort(result); delegate = new IteratorItemReader<LineStop>(result.iterator()); }