Search in sources :

Example 16 with SimpleJobTrigger

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

the class SchedulerResourceUtilTest method testUpdateStartDateForTimeZone_simple.

@Test
public void testUpdateStartDateForTimeZone_simple() throws Exception {
    SimpleJobTrigger sjt = new SimpleJobTrigger();
    sjt.setStartTime(now);
    when(scheduleRequest.getSimpleJobTrigger()).thenReturn(sjt);
    when(scheduleRequest.getTimeZone()).thenReturn("GMT");
    long gmtTime = now.getTime() + TimeZone.getTimeZone("EST").getRawOffset();
    SchedulerResourceUtil.updateStartDateForTimeZone(scheduleRequest);
    assertEquals(gmtTime, scheduleRequest.getSimpleJobTrigger().getStartTime().getTime());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) Test(org.junit.Test)

Example 17 with SimpleJobTrigger

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

the class PentahoBlockoutManagerIT method testGetBlockout.

/**
 * Test method for
 * {@link org.pentaho.platform.scheduler2.blockout.PentahoBlockoutManager#getBlockOut(java.lang.String)}.
 */
@Test
public void testGetBlockout() throws Exception {
    IJobTrigger blockOutJobTrigger1 = new SimpleJobTrigger(new Date(), null, -1, 1000000);
    IJobTrigger blockOutJobTrigger2 = new SimpleJobTrigger(new Date(), null, -1, 1000000);
    Job blockOutJob1 = addBlockOutJob(blockOutJobTrigger1);
    Job blockOutJob2 = addBlockOutJob(blockOutJobTrigger2);
    assertEquals(blockOutManager.getBlockOut(blockOutJob1.getJobId()).toString(), blockOutJobTrigger1.toString());
    assertEquals(blockOutManager.getBlockOut(blockOutJob2.getJobId()).toString(), blockOutJobTrigger2.toString());
    assertNotSame(blockOutJobTrigger1, blockOutManager.getBlockOut(blockOutJob2.getJobId()));
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Date(java.util.Date) Test(org.junit.Test)

Example 18 with SimpleJobTrigger

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

the class PentahoBlockoutManagerIT method testWillFire.

/**
 * Test method for
 * {@link org.pentaho.platform.scheduler2.blockout.PentahoBlockoutManager#willFire(org.quartz.IJobTrigger)}.
 */
@Test
public void testWillFire() throws Exception {
    Calendar blockOutStartDate = new GregorianCalendar(2013, Calendar.JANUARY, 7);
    IJobTrigger blockOutJobTrigger = new SimpleJobTrigger(blockOutStartDate.getTime(), null, -1, TIME.WEEK.time / 1000);
    blockOutJobTrigger.setDuration(duration);
    /*
     * Simple Schedule Triggers
     */
    Calendar scheduleStartDate = new GregorianCalendar(2013, Calendar.JANUARY, 7, 1, 0, 0);
    IJobTrigger trueScheduleTrigger = new SimpleJobTrigger(scheduleStartDate.getTime(), null, -1, TIME.DAY.time / 1000);
    IJobTrigger falseScheduleTrigger = new SimpleJobTrigger(scheduleStartDate.getTime(), null, -1, TIME.WEEK.time / 1000);
    Job blockOutJob = addBlockOutJob(blockOutJobTrigger);
    assertTrue(this.blockOutManager.willFire(trueScheduleTrigger));
    assertFalse(this.blockOutManager.willFire(falseScheduleTrigger));
    /*
     * Complex Schedule Triggers
     */
    IJobTrigger trueComplexScheduleTrigger = new ComplexJobTrigger();
    trueComplexScheduleTrigger.setStartTime(scheduleStartDate.getTime());
    // $NON-NLS-1$
    trueComplexScheduleTrigger.setCronString("0 0 1 ? * 2-3 *");
    IJobTrigger falseComplexScheduleTrigger = new ComplexJobTrigger();
    falseComplexScheduleTrigger.setStartTime(scheduleStartDate.getTime());
    // $NON-NLS-1$
    falseComplexScheduleTrigger.setCronString("0 0 1 ? * 2 *");
    assertTrue(this.blockOutManager.willFire(trueComplexScheduleTrigger));
    assertFalse(this.blockOutManager.willFire(falseComplexScheduleTrigger));
    /*
     * Complex Block out
     */
    deleteJob(blockOutJob.getJobId());
    blockOutJobTrigger = new ComplexJobTrigger();
    blockOutJobTrigger.setStartTime(blockOutStartDate.getTime());
    blockOutJobTrigger.setDuration(duration);
    // $NON-NLS-1$
    blockOutJobTrigger.setCronString("0 0 0 ? * 2 *");
    addBlockOutJob(blockOutJobTrigger);
    assertTrue(this.blockOutManager.willFire(trueScheduleTrigger));
    assertFalse(this.blockOutManager.willFire(falseScheduleTrigger));
    assertTrue(this.blockOutManager.willFire(trueComplexScheduleTrigger));
    assertFalse(this.blockOutManager.willFire(falseComplexScheduleTrigger));
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 19 with SimpleJobTrigger

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

the class PentahoBlockoutManagerIT method testIsPartiallyBlocked.

/**
 * Test method for
 * {@link org.pentaho.platform.scheduler2.blockout.PentahoBlockoutManager#isPartiallyBlocked(org.quartz.IJobTrigger)}.
 */
@Test
public void testIsPartiallyBlocked() throws Exception {
    Calendar blockOutStartDate = new GregorianCalendar(2013, Calendar.JANUARY, 1, 0, 0, 0);
    IJobTrigger blockOutTrigger = new SimpleJobTrigger(blockOutStartDate.getTime(), null, -1, TIME.WEEK.time * 2 / 1000);
    blockOutTrigger.setDuration(duration);
    /*
     * Simple Schedule Triggers
     */
    Calendar trueScheduleStartDate1 = new GregorianCalendar(2013, Calendar.JANUARY, 15, 0, 0, 0);
    IJobTrigger trueSchedule1 = new SimpleJobTrigger(trueScheduleStartDate1.getTime(), null, -1, TIME.WEEK.time * 2 / 1000);
    Calendar trueScheduleStartDate2 = new GregorianCalendar(2013, Calendar.JANUARY, 15, 0, 0, 0);
    IJobTrigger trueSchedule2 = new SimpleJobTrigger(trueScheduleStartDate2.getTime(), null, -1, TIME.WEEK.time / 1000);
    Calendar falseScheduleStartDate1 = new GregorianCalendar(2013, Calendar.JANUARY, 1, 3, 0, 0);
    IJobTrigger falseSchedule1 = new SimpleJobTrigger(falseScheduleStartDate1.getTime(), null, -1, TIME.WEEK.time / 1000);
    Job blockOutJob = addBlockOutJob(blockOutTrigger);
    assertTrue(this.blockOutManager.isPartiallyBlocked(trueSchedule1));
    assertTrue(this.blockOutManager.isPartiallyBlocked(trueSchedule2));
    assertFalse(this.blockOutManager.isPartiallyBlocked(falseSchedule1));
    /*
     * Complex Schedule Triggers
     */
    IJobTrigger trueComplexScheduleTrigger = new ComplexJobTrigger();
    trueComplexScheduleTrigger.setStartTime(trueScheduleStartDate1.getTime());
    // $NON-NLS-1$
    trueComplexScheduleTrigger.setCronString("0 0 1 ? * 2-3 *");
    IJobTrigger falseComplexScheduleTrigger = new ComplexJobTrigger();
    falseComplexScheduleTrigger.setStartTime(trueScheduleStartDate1.getTime());
    // $NON-NLS-1$
    falseComplexScheduleTrigger.setCronString("0 0 1 ? * 2 *");
    assertTrue(this.blockOutManager.isPartiallyBlocked(trueComplexScheduleTrigger));
    assertFalse(this.blockOutManager.isPartiallyBlocked(falseComplexScheduleTrigger));
    /*
     * Complex Block Out IJobTrigger
     */
    deleteJob(blockOutJob.getJobId());
    blockOutTrigger = new ComplexJobTrigger();
    blockOutTrigger.setStartTime(blockOutStartDate.getTime());
    // $NON-NLS-1$
    blockOutTrigger.setCronString("0 0 0 ? * 3 *");
    blockOutTrigger.setDuration(duration);
    addBlockOutJob(blockOutTrigger);
    assertTrue(this.blockOutManager.isPartiallyBlocked(trueSchedule1));
    assertTrue(this.blockOutManager.isPartiallyBlocked(trueSchedule2));
    assertFalse(this.blockOutManager.isPartiallyBlocked(falseSchedule1));
    assertTrue(this.blockOutManager.isPartiallyBlocked(trueComplexScheduleTrigger));
    assertFalse(this.blockOutManager.isPartiallyBlocked(falseComplexScheduleTrigger));
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) ComplexJobTrigger(org.pentaho.platform.api.scheduler2.ComplexJobTrigger) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Test(org.junit.Test)

Example 20 with SimpleJobTrigger

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

the class PentahoBlockoutManagerIT method testShouldFireNow.

/**
 * Test method for {@link org.pentaho.platform.scheduler2.blockout.PentahoBlockoutManager#shouldFireNow()}.
 */
@Test
public void testShouldFireNow() throws Exception {
    Date blockOutStartDate = new Date(System.currentTimeMillis());
    IJobTrigger blockOutJobTrigger = new SimpleJobTrigger(blockOutStartDate, null, -1, TIME.WEEK.time * 2 / 1000);
    blockOutJobTrigger.setDuration(duration);
    Job blockOutJob = addBlockOutJob(blockOutJobTrigger);
    assertFalse(this.blockOutManager.shouldFireNow());
    deleteJob(blockOutJob.getJobId());
    blockOutStartDate = new Date(System.currentTimeMillis() + TIME.HOUR.time);
    blockOutJobTrigger = new SimpleJobTrigger(blockOutStartDate, null, -1, TIME.WEEK.time * 2 / 1000);
    blockOutJobTrigger.setDuration(duration);
    addBlockOutJob(blockOutJobTrigger);
    assertTrue(this.blockOutManager.shouldFireNow());
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Job(org.pentaho.platform.api.scheduler2.Job) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)29 Test (org.junit.Test)23 Date (java.util.Date)14 Job (org.pentaho.platform.api.scheduler2.Job)14 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Serializable (java.io.Serializable)10 Calendar (java.util.Calendar)7 HashMap (java.util.HashMap)7 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)7 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)6 GregorianCalendar (java.util.GregorianCalendar)4 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)3 IBackgroundExecutionStreamProvider (org.pentaho.platform.api.scheduler2.IBackgroundExecutionStreamProvider)3 IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)3 JobScheduleParam (org.pentaho.platform.web.http.api.resources.JobScheduleParam)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Matchers.anyString (org.mockito.Matchers.anyString)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)2