Search in sources :

Example 56 with JobStatus

use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.

the class PinsetterTriggerListenerTest method triggerMisfireRunAgain.

@Test
public void triggerMisfireRunAgain() {
    PinsetterTriggerListener ptl = new PinsetterTriggerListener(modeManager, jobCurator);
    Trigger trigger = mock(Trigger.class);
    JobStatus jobStatus = new JobStatus();
    JobKey jobKey = new JobKey("mockName");
    when(trigger.mayFireAgain()).thenReturn(true);
    when(trigger.getJobKey()).thenReturn(jobKey);
    when(trigger.getNextFireTime()).thenReturn(new Date());
    when(jobCurator.find(Matchers.anyString())).thenReturn(jobStatus);
    ptl.triggerMisfired(trigger);
    assert (jobStatus.getResult().startsWith("Will reattempt job at or after"));
    assert (jobStatus.getState().equals(JobStatus.JobState.PENDING));
}
Also used : JobStatus(org.candlepin.pinsetter.core.model.JobStatus) JobKey(org.quartz.JobKey) Trigger(org.quartz.Trigger) Date(java.util.Date) Test(org.junit.Test)

Aggregations

JobStatus (org.candlepin.pinsetter.core.model.JobStatus)56 Test (org.junit.Test)43 JobDetail (org.quartz.JobDetail)22 JobKey (org.quartz.JobKey)10 ArrayList (java.util.ArrayList)7 CandlepinQuery (org.candlepin.model.CandlepinQuery)7 JobDataMap (org.quartz.JobDataMap)7 JobExecutionException (org.quartz.JobExecutionException)7 Trigger (org.quartz.Trigger)6 JobStatusDTO (org.candlepin.dto.api.v1.JobStatusDTO)5 TransformedCandlepinQuery (org.candlepin.model.TransformedCandlepinQuery)5 SchedulerException (org.quartz.SchedulerException)5 Principal (org.candlepin.auth.Principal)4 Date (java.util.Date)3 HashSet (java.util.HashSet)3 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)3 JobCurator (org.candlepin.model.JobCurator)3 MockResultIterator (org.candlepin.test.MockResultIterator)3 CronTrigger (org.quartz.CronTrigger)3 Transactional (com.google.inject.persist.Transactional)2