@Test
public void testAfterJobJobExecutionHasBatchStatusFailedWhenWeHaveStepsWithStatusNotCompleted() throws Exception {

    JobExecution jobExecution = new JobExecution(1L);
    StepExecution failedStepExecution = createStepExecution(jobExecution, FAILED);
    StepExecution completedStepExecution = createStepExecution(jobExecution, COMPLETED);
    StepExecution stoppedStepExecution = createStepExecution(jobExecution, STOPPED);
    jobExecution.addStepExecutions(asList(failedStepExecution, completedStepExecution, stoppedStepExecution));
    changeStatusOnFailedStepsJobExecListener.afterJob(jobExecution);
    assertThat(jobExecution.getStatus()).isEqualTo(BatchStatus.FAILED);
}