Search in sources :

Example 6 with IJobTrigger

use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.

the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_SimpleJobTrigger_basedOnExisting.

@Test
public void testConvertScheduleRequestToJobTrigger_SimpleJobTrigger_basedOnExisting() throws Exception {
    when(scheduleRequest.getSimpleJobTrigger()).thenReturn(simple);
    IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
    assertNotNull(trigger);
    assertEquals(simple, trigger);
    verify(simple).setStartTime(any(Date.class));
}
Also used : IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Date(java.util.Date) Test(org.junit.Test)

Example 7 with IJobTrigger

use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.

the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_daysOfWeek.

@Test
public void testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_daysOfWeek() throws Exception {
    complex.setDaysOfWeek(new int[] { 1, 5 });
    when(scheduleRequest.getComplexJobTrigger()).thenReturn(complex);
    IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
    assertNotNull(trigger);
    assertTrue(trigger instanceof ComplexJobTrigger);
    ComplexJobTrigger trig = (ComplexJobTrigger) trigger;
    List<ITimeRecurrence> recurrences = trig.getDayOfWeekRecurrences().getRecurrences();
    assertEquals(2, recurrences.size());
    RecurrenceList rec = (RecurrenceList) recurrences.get(0);
    assertEquals(2, rec.getValues().get(0).intValue());
    rec = (RecurrenceList) recurrences.get(1);
    assertEquals(6, rec.getValues().get(0).intValue());
}
Also used : ITimeRecurrence(org.pentaho.platform.api.scheduler2.recur.ITimeRecurrence) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) RecurrenceList(org.pentaho.platform.scheduler2.recur.RecurrenceList) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Test(org.junit.Test)

Example 8 with IJobTrigger

use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.

the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_monthsOfYear.

@Test
public void testConvertScheduleRequestToJobTrigger_ComplexJobTrigger_monthsOfYear() throws Exception {
    complex.setMonthsOfYear(new int[] { 1, 8 });
    when(scheduleRequest.getComplexJobTrigger()).thenReturn(complex);
    IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
    assertNotNull(trigger);
    assertTrue(trigger instanceof ComplexJobTrigger);
    ComplexJobTrigger trig = (ComplexJobTrigger) trigger;
    List<ITimeRecurrence> recurrences = trig.getMonthlyRecurrences().getRecurrences();
    assertEquals(2, recurrences.size());
    RecurrenceList rec = (RecurrenceList) recurrences.get(0);
    assertEquals(2, rec.getValues().get(0).intValue());
    rec = (RecurrenceList) recurrences.get(1);
    assertEquals(9, rec.getValues().get(0).intValue());
}
Also used : ITimeRecurrence(org.pentaho.platform.api.scheduler2.recur.ITimeRecurrence) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) RecurrenceList(org.pentaho.platform.scheduler2.recur.RecurrenceList) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Test(org.junit.Test)

Example 9 with IJobTrigger

use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.

the class SchedulerResourceUtilTest method testConvertScheduleRequestToJobTrigger_SimpleJobTrigger.

@Test
public void testConvertScheduleRequestToJobTrigger_SimpleJobTrigger() throws Exception {
    IJobTrigger trigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler);
    assertNotNull(trigger);
    assertTrue(trigger instanceof SimpleJobTrigger);
    assertTrue(trigger.getStartTime().getTime() > System.currentTimeMillis());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Test(org.junit.Test)

Example 10 with IJobTrigger

use of org.pentaho.platform.api.scheduler2.IJobTrigger in project pentaho-platform by pentaho.

the class QuartzScheduler method createJob.

/**
 * {@inheritDoc}
 */
public Job createJob(String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams, IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider) throws SchedulerException {
    if (action == null) {
        // $NON-NLS-1$
        throw new SchedulerException(Messages.getInstance().getString("QuartzScheduler.ERROR_0003_ACTION_IS_NULL"));
    }
    if (jobParams == null) {
        jobParams = new HashMap<String, Serializable>();
    }
    jobParams.put(RESERVEDMAPKEY_ACTIONCLASS, action.getName());
    Job ret = createJob(jobName, jobParams, trigger, outputStreamProvider);
    ret.setSchedulableClass(action.getName());
    return ret;
}
Also used : Serializable(java.io.Serializable) SchedulerException(org.pentaho.platform.api.scheduler2.SchedulerException) Job(org.pentaho.platform.api.scheduler2.Job)

Aggregations

IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)28 Test (org.junit.Test)18 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)13 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)12 Job (org.pentaho.platform.api.scheduler2.Job)11 Date (java.util.Date)8 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)7 ITimeRecurrence (org.pentaho.platform.api.scheduler2.recur.ITimeRecurrence)6 Serializable (java.io.Serializable)4 Calendar (java.util.Calendar)4 GregorianCalendar (java.util.GregorianCalendar)4 RecurrenceList (org.pentaho.platform.scheduler2.recur.RecurrenceList)4 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)3 QualifiedDayOfWeek (org.pentaho.platform.scheduler2.recur.QualifiedDayOfWeek)3 Trigger (org.quartz.Trigger)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 IAction (org.pentaho.platform.api.action.IAction)2 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)2 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)2