assertEquals(expected, result);
}
@Test
public void cancelOrphanedJobs() throws InterruptedException {
JobStatus status1 = newJobStatus().state(JobStatus.JobState.WAITING)
.id("1").create();
JobStatus status2 = newJobStatus().state(JobStatus.JobState.WAITING)
.id("2").create();
JobStatus status3 = newJobStatus().state(JobStatus.JobState.RUNNING)
.id("3").create();
JobStatus status4 = newJobStatus().state(JobStatus.JobState.CREATED)
.id("4").create();
JobStatus status5 = newJobStatus().state(JobStatus.JobState.RUNNING)
.id("5").create();
List<String> activeIds = new LinkedList<String>();
activeIds.add(status1.getId());
activeIds.add(status3.getId());
activeIds.add(status4.getId());
int updated = curator.cancelOrphanedJobs(activeIds, 0L);
assertEquals(2, updated);
curator.refresh(status1);
curator.refresh(status2);
curator.refresh(status3);
curator.refresh(status4);
curator.refresh(status5);
assertEquals(JobStatus.JobState.WAITING, status1.getState());
assertEquals(JobStatus.JobState.CANCELED, status2.getState());
assertEquals(JobStatus.JobState.RUNNING, status3.getState());
assertEquals(JobStatus.JobState.CREATED, status4.getState());
assertEquals(JobStatus.JobState.CANCELED, status5.getState());
}