//setup
String jobName = "test_job";
JobRepository jobRepository = mock(JobRepository.class);
JobParameters parameters = new JobParametersBuilder().addLong("runtime", System.currentTimeMillis()).toJobParameters();
JobExecution jobExecution = mock(JobExecution.class);
Job job = mock(Job.class);
JobParametersValidator validator = mock(JobParametersValidator.class);
StepExecution stepExecution = mock(StepExecution.class);
when(job.getName()).thenReturn(jobName);
when(job.isRestartable()).thenReturn(true);
when(job.getJobParametersValidator()).thenReturn(validator);
when(jobRepository.getLastJobExecution(jobName, parameters)).thenReturn(jobExecution);
when(stepExecution.getStatus()).thenReturn(BatchStatus.UNKNOWN);
when(jobExecution.getStepExecutions()).thenReturn(Arrays.asList(stepExecution));
//setup launcher