use of org.quartz.ListenerManager in project candlepin by candlepin.
the class HypervisorUpdateJobTest method dontSkipIfExistsTest.
/*
* Schedule the job to be executed later even if a similar job exists.
*/
@Test
public void dontSkipIfExistsTest() throws JobExecutionException, SchedulerException {
JobDetail detail = HypervisorUpdateJob.forOwner(owner, hypervisorJson, true, principal, null);
JobStatus preExistingJobStatus = new JobStatus();
preExistingJobStatus.setState(JobState.WAITING);
HypervisorUpdateJob job = new HypervisorUpdateJob(ownerCurator, consumerCurator, consumerTypeCurator, consumerResource, i18n, subAdapter, complianceRules);
JobStatus newlyScheduledJobStatus = new JobStatus();
JobCurator jobCurator = mock(JobCurator.class);
Scheduler scheduler = mock(Scheduler.class);
ListenerManager lm = mock(ListenerManager.class);
when(jobCurator.getByClassAndTarget(anyString(), any(Class.class))).thenReturn(preExistingJobStatus);
when(scheduler.getListenerManager()).thenReturn(lm);
when(jobCurator.create(any(JobStatus.class))).thenReturn(newlyScheduledJobStatus);
JobStatus resultStatus = job.scheduleJob(jobCurator, scheduler, detail, null);
assertEquals(newlyScheduledJobStatus, resultStatus);
}
Aggregations