Package org.pentaho.platform.api.scheduler2

Examples of org.pentaho.platform.api.scheduler2.SimpleJobTrigger


    Assert.assertFalse( trigger.getRepeatCount() != 0 && trigger.getRepeatInterval() < 1 );
  }

  @Test
  public void defaultParamsNoDatesTest() {
    SimpleJobTrigger trigger = new SimpleJobTrigger();
    Assert.assertEquals( trigger.toString(), "repeatCount=0, repeatInterval=0, startTime=null, endTime=null" );
  }
View Full Code Here


  @Test
  public void defaultParamsDatesTest() {
    Calendar now = Calendar.getInstance();
    Calendar nextMonth = Calendar.getInstance();
    nextMonth.add( Calendar.MONTH, 1 );
    SimpleJobTrigger trigger = new SimpleJobTrigger( now.getTime(), nextMonth.getTime(), 1, 1000 );
    Assert.assertEquals( trigger.toString(), "repeatCount=1, repeatInterval=1000, startTime="
        + now.getTime().toString() + ", endTime=" + nextMonth.getTime().toString() );
  }
View Full Code Here

   * 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() ) );
  }
View Full Code Here

    assertNotSame( blockOutJobTrigger1, blockOutManager.getBlockOut( blockOutJob2.getJobId() ) );
  }

  @Test
  public void testGetBlockouts() throws Exception {
    IJobTrigger trigger1 = new SimpleJobTrigger( new Date(), null, -1, 1000000 );
    IJobTrigger trigger2 = new SimpleJobTrigger( new Date(), null, -1, 1000000 );
    addBlockOutJob( trigger1 );
    addBlockOutJob( trigger2 );

    assertEquals( 2, this.blockOutManager.getBlockOutJobs().size() );
  }
View Full Code Here

   */
  @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 ) );

View Full Code Here

   */
  @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 ) );
View Full Code Here

   * 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() );
  }
View Full Code Here

   */
  @Test
  public void testWillBlockSchedules() throws Exception {
    Calendar trueBlockOutStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 7 );
    IJobTrigger trueBlockOutTrigger =
        new SimpleJobTrigger( trueBlockOutStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
    trueBlockOutTrigger.setDuration( duration );

    Calendar falseBlockOutStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 9 );
    IJobTrigger falseBlockOutTrigger =
        new SimpleJobTrigger( falseBlockOutStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
    falseBlockOutTrigger.setDuration( duration );

    IJobTrigger trueComplexBlockOutTrigger = new ComplexJobTrigger();
    trueComplexBlockOutTrigger.setStartTime( trueBlockOutStartDate.getTime() );
    trueComplexBlockOutTrigger.setCronString( "0 0 0 ? * 2 *" ); //$NON-NLS-1$
    trueComplexBlockOutTrigger.setDuration( duration );

    IJobTrigger falseComplexBlockOutTrigger = new ComplexJobTrigger();
    falseComplexBlockOutTrigger.setStartTime( falseBlockOutStartDate.getTime() );
    falseComplexBlockOutTrigger.setCronString( "0 0 0 ? * WED *" ); //$NON-NLS-1$
    falseComplexBlockOutTrigger.setDuration( duration );

    Calendar scheduleStartDate = new GregorianCalendar( 2013, Calendar.JANUARY, 7, 1, 0, 0 );
    IJobTrigger scheduleTrigger = new SimpleJobTrigger( scheduleStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );
    addJob( scheduleTrigger, "scheduleTrigger" ); //$NON-NLS-1$

    assertEquals( 1, this.blockOutManager.willBlockSchedules( trueBlockOutTrigger ).size() );
    assertEquals( 1, this.blockOutManager.willBlockSchedules( trueComplexBlockOutTrigger ).size() );
    assertEquals( 0, this.blockOutManager.willBlockSchedules( falseBlockOutTrigger ).size() );
View Full Code Here

  @Test
  public void testUpdateSimpleJob() throws SchedulerException {
  long start  = System.currentTimeMillis() + 1000;
  long end = System.currentTimeMillis() + 1000 + 5*60*60*100;
    SimpleJobTrigger jobTrigger = new SimpleJobTrigger();
    jobTrigger.setStartTime( new Date(start) );
    jobTrigger.setEndTime( new Date(end) );
    jobTrigger.setRepeatInterval( 10 );
    jobTrigger.setRepeatCount( 20 );
    System.out.println( jobTrigger.toString() );

    String jobId = schedulerSvc.createSimpleJob( "test job", jobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );

    jobTrigger = new SimpleJobTrigger();

  start  = System.currentTimeMillis() + 1000;
  end = System.currentTimeMillis() + 1000 + 5*60*60*100;

    jobTrigger.setStartTime( new Date(start));
    jobTrigger.setEndTime( new Date(end) );

    jobTrigger.setRepeatInterval( 40 );
    jobTrigger.setRepeatCount( 50 );
    System.out.println( jobTrigger.toString() );

    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>( jobParams );
    newJobParams.put( "newKey", new StringParamValue( "" ) );
    schedulerSvc.updateJobToUseSimpleTrigger( jobId, newJobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );
    Job job = schedulerSvc.getJobs()[0];
    jobTrigger = (SimpleJobTrigger) job.getJobTrigger();
    Assert.assertEquals( 40, jobTrigger.getRepeatInterval() );
    Assert.assertEquals( 50, jobTrigger.getRepeatCount() );
    Assert.assertTrue( job.getJobParams().containsKey( "newKey" ) );

    jobTrigger.getStartTime() ;
    Assert.assertEquals( new Date(start), jobTrigger.getStartTime());

    Assert.assertEquals( new Date(end), jobTrigger.getEndTime() );
  }
View Full Code Here

    Assert.assertTrue( "testStringVal".equals( unmarshalledJob.jobParams.entry.get( 0 ).getStringValue().toString() ) );
  }

  @Test
  public void testSimpleTrigger() throws JAXBException {
    SimpleJobTrigger orig = new SimpleJobTrigger();
    Date STARTTIME = new Date();
    orig.setStartTime( STARTTIME );

    SimpleJobTrigger unmarshalled = JaxBUtil.outin( orig, SimpleJobTrigger.class );

    Assert.assertEquals( orig.getStartTime(), unmarshalled.getStartTime() );
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.scheduler2.SimpleJobTrigger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.