StoreDelayGreaterThanThresholdInContextProcessor implements ItemProcessor<BatchExcelRow, BatchExcelRow>, InitializingBean { @Override public BatchExcelRow process(final BatchExcelRow item) throws Exception { if (item.getDelay() < Delays.toMillis(threshold)) { LOGGER.debug("delay<" + threshold, item); } else { LOGGER.debug("delay>=" + threshold, item); storeInContext(item); } return item; }  @BeforeStep void beforeStep(StepExecution stepExecution); @Override void afterPropertiesSet(); @Override BatchExcelRow process(final BatchExcelRow item); void setThreshold(Long threshold); void setKeyName(String keyName);  }
@Test public void testThatItemIsNotFiltered() throws Exception { input.delay(Delays.toMillis(59L)); Assert.assertNotNull(processor.process(input.build(false))); }
@Test public void testThatTrainIdIsInTheContext() throws Exception { input.delay(Delays.toMillis(61L)); processor.process(input.build(false)); Assert.assertEquals(input.build(false), ((Map) stepExecution.getExecutionContext().get(KEY_NAME)).get(Sens.DEPARTURE)); }
@Test public void testThat2TrainIdsAreInTheContext() throws Exception { processor.process(new BatchExcelRow .Builder(LocalDate.now(), Sens.DEPARTURE) .expectedTrain1(RaildelaysTestUtils.generateTrain(466L)) .delay(Delays.toMillis(75L)) .build(false)); processor.process(new BatchExcelRow .Builder(LocalDate.now(), Sens.ARRIVAL) .expectedTrain1(RaildelaysTestUtils.generateTrain(466L)) .delay(Delays.toMillis(66L)) .build(false)); Assert.assertNotNull(((Map) stepExecution.getExecutionContext().get(KEY_NAME)).get(Sens.DEPARTURE)); Assert.assertNotNull(((Map) stepExecution.getExecutionContext().get(KEY_NAME)).get(Sens.ARRIVAL)); }