@Before
	public void before() throws Exception {
		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(jobLocator.getJobNames()).thenReturn(jobNames);
		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.getJobInstance(jobInstance1.getInstanceId())).thenReturn(jobInstance1);
		when(jobService.getJobExecutionsForJobInstance(jobInstance1.getJobName(), jobInstance1.getInstanceId())).thenReturn(
				jobExecutions2);
		when(jobService.getJobInstance(100)).thenThrow(new NoSuchBatchJobInstanceException(100));
		when(jobService.getJobInstance(101)).thenReturn(jobInstance2);
		when(jobService.getJobExecutionsForJobInstance("job2", jobInstance2.getInstanceId())).thenThrow(
				new NoSuchJobException("job2"));
	}
Tests REST compliance of {@link BatchJobInstancesController} endpoints.

@author Ilayaperumal Gopinathan
spring-xd-dirt/src/test/java/org/springframework/xd/dirt/rest/BatchJobInstancesControllerIntegrationTests.java