@Test public void testAfterJobJobExecutionHasBatchStatusUnchangedWhenAllStepsCompleted() throws Exception { JobExecution jobExecution = new JobExecution(1L); StepExecution completedStepExecution = createStepExecution(jobExecution, COMPLETED); StepExecution anotherStepExecution = createStepExecution(jobExecution, COMPLETED); jobExecution.addStepExecutions(asList(completedStepExecution, anotherStepExecution)); BatchStatus jobExecutionStatus = jobExecution.getStatus(); changeStatusOnFailedStepsJobExecListener.afterJob(jobExecution); assertThat(jobExecution.getStatus()).isEqualTo(jobExecutionStatus); }
@Override public void afterJob(JobExecution jobExecution) { List<StepExecution> failedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) .collect(Collectors.toList()); if (failedStepExecutions.size() > 0) { jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setExitStatus(new ExitStatus("FAILED-BECAUSE-OF-SKIPS")); } }
ChangeStatusOnFailedStepsJobExecListener extends JobExecutionListenerSupport { @Override public void afterJob(JobExecution jobExecution) { List<StepExecution> failedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) .collect(Collectors.toList()); if (failedStepExecutions.size() > 0) { jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setExitStatus(new ExitStatus("FAILED-BECAUSE-OF-SKIPS")); } } }
ChangeStatusOnFailedStepsJobExecListener extends JobExecutionListenerSupport { @Override public void afterJob(JobExecution jobExecution) { List<StepExecution> failedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) .collect(Collectors.toList()); if (failedStepExecutions.size() > 0) { jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setExitStatus(new ExitStatus("FAILED-BECAUSE-OF-SKIPS")); } }  }
ChangeStatusOnFailedStepsJobExecListener extends JobExecutionListenerSupport { @Override public void afterJob(JobExecution jobExecution) { List<StepExecution> failedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) .collect(Collectors.toList()); if (failedStepExecutions.size() > 0) { jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setExitStatus(new ExitStatus("FAILED-BECAUSE-OF-SKIPS")); } }  @Override void afterJob(JobExecution jobExecution); }
ChangeStatusOnFailedStepsJobExecListener extends JobExecutionListenerSupport { @Override public void afterJob(JobExecution jobExecution) { List<StepExecution> failedStepExecutions = jobExecution.getStepExecutions() .stream() .filter(stepExecution -> stepExecution.getExitStatus().getExitCode().equals(ExitStatus.FAILED.getExitCode())) .collect(Collectors.toList()); if (failedStepExecutions.size() > 0) { jobExecution.setStatus(BatchStatus.FAILED); jobExecution.setExitStatus(new ExitStatus("FAILED-BECAUSE-OF-SKIPS")); } }  @Override void afterJob(JobExecution jobExecution);  }