Source:
public void before() throws Exception { final SimpleJob job1 = new SimpleJob("job1.job"); final JobInstance jobInstance1 = new JobInstance(0l, job1.getName()); final Map<String, JobParameter> parametersMap1 = new HashMap<String, JobParameter>(); parametersMap1.put("param1", new JobParameter("test", true)); parametersMap1.put("param2", new JobParameter(123l, false)); final JobParameters jobParameters1 = new JobParameters(parametersMap1); final JobExecution jobExecution1 = new JobExecution(jobInstance1, 2l, jobParameters1); final StepExecution step1 = new StepExecution("step1", jobExecution1, 1L); final StepExecution step2 = new StepExecution("step2", jobExecution1, 2L); final StepExecution step3 = new StepExecution("step3", jobExecution1, 3L); final List<StepExecution> stepExecutions1 = new ArrayList<StepExecution>(); stepExecutions1.add(step1); stepExecutions1.add(step2); stepExecutions1.add(step3); final List<StepExecution> stepExecutions2 = new ArrayList<StepExecution>(); stepExecutions2.add(step2); jobExecution1.addStepExecutions(stepExecutions1); when(jobService.getStepExecutions(5555L)).thenThrow( new NoSuchJobExecutionException("No JobExecution with id=5555L")); when(jobService.getStepExecutions(2L)).thenReturn(stepExecutions1); when(jobService.getStepExecution(2L, 1L)).thenReturn(step1); when(jobService.getStepExecution(5555L, 1L)).thenThrow( new NoSuchJobExecutionException("No JobExecution with id=5555L")); when(jobService.getStepExecution(2L, 5555L)).thenThrow( new NoSuchStepExecutionException("No StepExecution with id=5555L")); when(jobService.countStepExecutionsForStep(job1.getName(), step1.getStepName())).thenReturn(1); when(jobService.listStepExecutionsForStep(job1.getName(), step1.getStepName(), 0, 1000)).thenReturn( stepExecutions2); }

Target:
public void before() throws Exception { final SimpleJob job1 = new SimpleJob("job1.job"); final JobInstance jobInstance1 = new JobInstance(0L, job1.getName()); final Map<String, JobParameter> parametersMap1 = new HashMap<String, JobParameter>(); parametersMap1.put("param1", new JobParameter("test", true)); parametersMap1.put("param2", new JobParameter(123L, false)); final JobParameters jobParameters1 = new JobParameters(parametersMap1); final JobExecution jobExecution1 = new JobExecution(jobInstance1, 2L, jobParameters1); final StepExecution step1 = new StepExecution("step1", jobExecution1, 1L); final StepExecution step2 = new StepExecution("step2", jobExecution1, 2L); final StepExecution step3 = new StepExecution("step3", jobExecution1, 3L); final List<StepExecution> stepExecutions1 = new ArrayList<StepExecution>(); stepExecutions1.add(step1); stepExecutions1.add(step2); stepExecutions1.add(step3); final List<StepExecution> stepExecutions2 = new ArrayList<StepExecution>(); stepExecutions2.add(step2); jobExecution1.addStepExecutions(stepExecutions1); when(jobService.getStepExecutions(5555L)).thenThrow( new NoSuchJobExecutionException("No JobExecution with id=5555L")); when(jobService.getStepExecutions(2L)).thenReturn(stepExecutions1); when(jobService.getStepExecution(2L, 1L)).thenReturn(step1); when(jobService.getStepExecution(5555L, 1L)).thenThrow( new NoSuchJobExecutionException("No JobExecution with id=5555L")); when(jobService.getStepExecution(2L, 5555L)).thenThrow( new NoSuchStepExecutionException("No StepExecution with id=5555L")); when(jobService.countStepExecutionsForStep(job1.getName(), step1.getStepName())).thenReturn(1); when(jobService.listStepExecutionsForStep(job1.getName(), step1.getStepName(), 0, 1000)).thenReturn( stepExecutions2); }