FailedStepStepExecutionListener implements StepExecutionListener { @Override public ExitStatus afterStep(StepExecution stepExecution) { if (someItemsGotSkippedDueToTaxWebServiceExceptions(stepExecution)) { return ExitStatus.FAILED; } return ExitStatus.COMPLETED; }  @Override void beforeStep(StepExecution stepExecution); @Override ExitStatus afterStep(StepExecution stepExecution);  }
@Test public void testAfterStep_returns_FailedExitStatus_whenRead_And_Write_Count_Dont_Match() throws Exception { stepExecution.setReadCount(2); stepExecution.setWriteCount(1); ExitStatus exitStatus = failedStepStepExecutionListener.afterStep(stepExecution); assertThat(exitStatus).isEqualTo(ExitStatus.FAILED); }
@Test public void testAfterStep_returns_CompletedExitStatus_whenRead_And_Write_Match() throws Exception { stepExecution.setReadCount(2); stepExecution.setWriteCount(2); ExitStatus exitStatus = failedStepStepExecutionListener.afterStep(stepExecution); assertThat(exitStatus).isEqualTo(ExitStatus.COMPLETED); }