moduleDefinitions.add(moduleJobDefinition);
when(moduleRegistry.findDefinitions("job")).thenReturn(moduleDefinitions);
when(moduleRegistry.findDefinition("job", ModuleType.job)).thenReturn(moduleJobDefinition);
when(jobLocator.getJobNames()).thenReturn(Arrays.asList(new String[] {}));
SimpleJob job1 = new SimpleJob("job1");
SimpleJob job2 = new SimpleJob("job2");
Collection<String> jobNames = new ArrayList<String>();
jobNames.add(job1.getName());
jobNames.add(job2.getName());
Collection<JobInstance> jobInstances = new ArrayList<JobInstance>();
JobInstance jobInstance1 = new JobInstance(0l, job1.getName());
JobInstance jobInstance2 = new JobInstance(2l, job2.getName());
JobInstance jobInstance3 = new JobInstance(3l, job1.getName());
jobInstances.add(jobInstance1);
jobInstances.add(jobInstance3);
Map<String, JobParameter> parametersMap1 = new HashMap<String, JobParameter>();
parametersMap1.put("param1", new JobParameter("test", true));
parametersMap1.put("param2", new JobParameter(123l, false));
JobParameters jobParameters1 = new JobParameters(parametersMap1);
JobParameters jobParameters2 = new JobParameters(parametersMap1);
JobExecution jobExecution1 = new JobExecution(jobInstance1, 0l, jobParameters1, null);
JobExecution jobExecution2 = new JobExecution(jobInstance2, 3l, jobParameters2, null);
// Verify XD-999
StepExecution stepExecution = new StepExecution("s1", jobExecution2);
List<StepExecution> stepExecutions = new ArrayList<StepExecution>();
stepExecutions.add(stepExecution);
jobExecution2.addStepExecutions(stepExecutions);
Collection<JobExecution> jobExecutions1 = new ArrayList<JobExecution>();
Collection<JobExecution> jobExecutions2 = new ArrayList<JobExecution>();
jobExecutions1.add(jobExecution1);
jobExecutions1.add(jobExecution2);
jobExecutions2.add(jobExecution2);
when(jobService.countJobExecutionsForJob(job1.getName())).thenReturn(2);
when(jobService.countJobExecutionsForJob(job2.getName())).thenReturn(1);
when(jobService.isLaunchable(job1.getName())).thenReturn(false);
when(jobService.isLaunchable(job2.getName())).thenReturn(true);
when(jobService.isIncrementable(job1.getName())).thenReturn(false);
when(jobService.isIncrementable(job2.getName())).thenReturn(true);
when(jobService.listJobInstances(job1.getName(), 0, 20)).thenReturn(jobInstances);
Date startTime = new Date();
Date endTime = new Date();
Collection<JobExecution> jobExecutions = new ArrayList<JobExecution>();
execution = new JobExecution(0L,
new JobParametersBuilder().addString("foo", "bar").addLong("foo2", 0L).toJobParameters());
execution.setExitStatus(ExitStatus.COMPLETED);
execution.setStartTime(startTime);
execution.setEndTime(endTime);
jobExecutions.add(execution);
when(jobService.listJobExecutionsForJob("job1", 0, 1)).thenReturn(jobExecutions);
when(jobService.listJobExecutions(0, 20)).thenReturn(jobExecutions1);
when(jobService.listJobExecutionsForJob(job2.getName(), 0, 20)).thenReturn(jobExecutions2);
}