@Test
  public void testSimpleJob() throws Exception {

    JobInstance jobInstance = MetaDataInstanceFactory.createJobInstance("foo", 11L);
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution("foo", 11L, 123L);
    jobExecution.setEndTime(new Date());
    jobExecution.setStatus(BatchStatus.FAILED);

    when(jobExplorer.getJobInstances("foo", 0, 100)).thenReturn(Arrays.asList(jobInstance));
    when(jobExplorer.getJobExecutions(jobInstance)).thenReturn(Arrays.asList(jobExecution));

    JobLaunchRequest request = adapter.adapt("foo");
    assertEquals("foo", request.getJob().getName());
    assertEquals(0, request.getJobParameters().getParameters().size());
  }
  @Test
  public void testSimpleJobNotFailed() throws Exception {

    thrown.expect(JobParametersNotFoundException.class);
    thrown.expectMessage("No failed or stopped execution");

    JobInstance jobInstance = MetaDataInstanceFactory.createJobInstance("foo", 11L);
    JobExecution jobExecution = MetaDataInstanceFactory.createJobExecution("foo", 11L, 123L);
    jobExecution.setEndTime(new Date());
    jobExecution.setStatus(BatchStatus.COMPLETED);

    when(jobExplorer.getJobInstances("foo", 0, 100)).thenReturn(Arrays.asList(jobInstance));
    when(jobExplorer.getJobExecutions(jobInstance)).thenReturn(Arrays.asList(jobExecution));
    when(jobExplorer.getJobInstances("foo", 100, 100)).thenReturn(new ArrayList<JobInstance>());

    adapter.adapt("foo");
  }