ExcelFileToRenameOrDeleteDecider extends AbstractReadAndDecideTasklet<ExcelRow> implements InitializingBean { @Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); Assert.notNull(this.reader, "The 'reader' property must be provided"); Assert.notNull(this.directory, "The 'directory' property must be provided"); Assert.notNull(this.contextKey, "The 'contextKey' property must be provided"); Assert.notNull(this.fileNamePrefix, "The 'fileNamePrefix' property must be provided"); }  @Override void afterPropertiesSet(); @Override ExitStatus doRead(StepContribution contribution, ExecutionContext context, ExcelRow item); void setFileNamePrefix(String fileNamePrefix); void setDirectory(Resource directory); void setContextKey(String contextKey); static final ExitStatus RENAME; static final ExitStatus DELETE; }
@Test public void testRename() 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, null) .build(false), new ExcelRow.Builder(NOW .plus(1, ChronoUnit.MONTHS), Sens.ARRIVAL) .build(false) )))); decider.afterPropertiesSet(); FlowExecutionStatus status = decider.decide(jobExecution, stepExecution); Assert.assertEquals(RENAME, status); }
@Test public void testDelete() throws Exception { decider.setReader(new ItemStreamItemReaderDelegator<>(new IteratorItemReader<>(Arrays.asList( new ExcelRow .Builder(null, null) .build(false), new ExcelRow .Builder(NOW.minus(1, ChronoUnit.MONTHS), 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(DELETE, status); }