MaxMonthsDecider extends AbstractReadAndDecideTasklet<ExcelRow> implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(this.maxNumberOfMonth, "The 'maxNumberOfMonth' property must be provided"); Assert.notNull(this.reader, "The 'reader' property must be provided"); }  @Override void afterPropertiesSet(); void setMaxNumberOfMonth(long maxNumberOfMonth); static final ExitStatus COMPLETED_WITH_MAX_MONTHS; }
@Test public void testCompleted() throws Exception { decider.setReader(new ItemStreamItemReaderDelegator<>(new IteratorItemReader<>(Arrays.asList( new ExcelRow .Builder(NOW.minus(1, ChronoUnit.MONTHS), Sens.ARRIVAL) .build(false), new ExcelRow .Builder(null, Sens.ARRIVAL) .build(false), new ExcelRow .Builder(NOW.plus(1, ChronoUnit.MONTHS), Sens.ARRIVAL) .build(false) )))); decider.afterPropertiesSet(); FlowExecutionStatus status = decider.decide(jobExecution, stepExecution); Assert.assertEquals(FlowExecutionStatus.COMPLETED, status); }
@Test public void testCompletedWithMaxMonths() throws Exception { decider.setReader(new ItemStreamItemReaderDelegator<>(new IteratorItemReader<>(Arrays.asList( new ExcelRow .Builder(NOW.minus(6, ChronoUnit.MONTHS), Sens.ARRIVAL) .build(false), new ExcelRow .Builder(null, Sens.ARRIVAL) .build(false), new ExcelRow .Builder(NOW.plus(2, ChronoUnit.MONTHS), Sens.ARRIVAL) .build(false) )))); decider.afterPropertiesSet(); FlowExecutionStatus status = decider.decide(jobExecution, stepExecution); Assert.assertTrue(stepExecution.getExecutionContext() .entrySet() .stream() .anyMatch(entry -> entry.getKey().equals("threshold.date"))); Assert.assertEquals(COMPLETED_WITH_MAX_MONTHS, status); }