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());
}
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()));
}
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));
}
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));
}
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());
}
Aggregations