Search in sources :

Example 1 with ListenerManager

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);
}
Also used : JobStatus(org.candlepin.pinsetter.core.model.JobStatus) JobDetail(org.quartz.JobDetail) Scheduler(org.quartz.Scheduler) JobCurator(org.candlepin.model.JobCurator) ListenerManager(org.quartz.ListenerManager) Test(org.junit.Test)

Aggregations

JobCurator (org.candlepin.model.JobCurator)1 JobStatus (org.candlepin.pinsetter.core.model.JobStatus)1 Test (org.junit.Test)1 JobDetail (org.quartz.JobDetail)1 ListenerManager (org.quartz.ListenerManager)1 Scheduler (org.quartz.Scheduler)1