@Test
public void testBuildWithStopAndRestart() throws Exception {
SimpleJobBuilder builder = new JobBuilder("flow").repository(jobRepository).start(fails);
builder.on("FAILED").stopAndRestart(step2);
Job job = builder.build();
job.execute(execution);
assertEquals(BatchStatus.STOPPED, execution.getStatus());
assertEquals(1, execution.getStepExecutions().size());
execution = jobRepository.createJobExecution("flow", new JobParameters());
job.execute(execution);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
assertEquals(1, execution.getStepExecutions().size());
assertEquals("step2", execution.getStepExecutions().iterator().next().getStepName());
}