Package org.pentaho.platform.scheduler2.quartz.test

Examples of org.pentaho.platform.scheduler2.quartz.test.ComplexTriggerTest


      if ( proxyTrigger.getDaysOfWeek().length > 0 ) {
        if ( proxyTrigger.getWeeksOfMonth().length > 0 ) {
          for ( int dayOfWeek : proxyTrigger.getDaysOfWeek() ) {
            for ( int weekOfMonth : proxyTrigger.getWeeksOfMonth() ) {

              QualifiedDayOfWeek qualifiedDayOfWeek = new QualifiedDayOfWeek();
              qualifiedDayOfWeek.setDayOfWeek( DayOfWeek.values()[dayOfWeek] );

              if ( weekOfMonth == JobScheduleRequest.LAST_WEEK_OF_MONTH ) {
                qualifiedDayOfWeek.setQualifier( DayOfWeekQualifier.LAST );
              } else {
                qualifiedDayOfWeek.setQualifier( DayOfWeekQualifier.values()[weekOfMonth] );
              }
              complexJobTrigger.addDayOfWeekRecurrence( qualifiedDayOfWeek );
            }
          }
        } else {
View Full Code Here


              dayOfWeekRecurrence.add( new IncrementalRecurrence( Integer.parseInt( days[0] ), Integer
                  .parseInt( days[1] ) ) );
            } else if ( qualifiedDayPattern.matcher( token ).matches() ) {
              String[] days = token.split( "#" ); //$NON-NLS-1$
              dayOfWeekRecurrence
                  .add( new QualifiedDayOfWeek( Integer.parseInt( days[1] ), Integer.parseInt( days[0] ) ) );
            } else if ( lastDayPattern.matcher( token ).matches() ) {
              DayOfWeek dayOfWeek =
                  DayOfWeek.values()[( Integer.parseInt( token.substring( 0, token.length() - 1 ) ) - 1 ) % 7];
              dayOfWeekRecurrence.add( new QualifiedDayOfWeek( DayOfWeekQualifier.LAST, dayOfWeek ) );
            } else if ( dayOfWeekRangePattern.matcher( token ).matches() ) {
              String[] days = token.split( "-" ); //$NON-NLS-1$
              int start = DayOfWeek.valueOf( days[0] ).ordinal();
              int finish = DayOfWeek.valueOf( days[1] ).ordinal();
              dayOfWeekRecurrence.add( new SequentialRecurrence( start, finish ) );
View Full Code Here

        new Integer( 30 ) );
    Assert.assertEquals( ( (SequentialRecurrence) trigger.getMinuteRecurrences().get( 0 ) ).getLastValue(),
        new Integer( 45 ) );

    trigger = new ComplexJobTrigger();
    trigger.addDayOfWeekRecurrence( new QualifiedDayOfWeek( DayOfWeekQualifier.LAST, DayOfWeek.FRI ) );
    System.out.println( trigger.toString() );
    Assert.assertEquals( trigger.toString(), "0 0 0 ? * 6L *" );

    trigger = new ComplexJobTrigger();
    trigger.addDayOfWeekRecurrence( new QualifiedDayOfWeek( DayOfWeekQualifier.LAST, DayOfWeek.FRI ) );
    trigger.addDayOfWeekRecurrence( new QualifiedDayOfWeek( DayOfWeekQualifier.THIRD, DayOfWeek.SUN ) );
    System.out.println( trigger.toString() );
    Assert.assertEquals( trigger.toString(), "0 0 0 ? * 6L,1#3 *" );

    trigger = QuartzScheduler.createComplexTrigger( "* 0 0 ? * 6L,1#3 *" );
    Assert.assertEquals( trigger.getDayOfWeekRecurrences().size(), 2 );
View Full Code Here

        Assert.assertEquals( "Wrong first value for dimension " + dimension, list[0], l.getValues().get( 0 ) );
        Assert.assertEquals( "Wrong second value for dimension " + dimension, list[1], l.getValues().get( 1 ) );
      }
      if ( rec instanceof QualifiedDayOfWeek ) {
        count++;
        QualifiedDayOfWeek q = (QualifiedDayOfWeek) rec;
        Assert.assertEquals( "Wrong day of week for dimension " + dimension, qday.getDayOfWeek(), q.getDayOfWeek() );
        Assert.assertEquals( "Wrong qualifier for dimension " + dimension, qday.getQualifier(), q.getQualifier() );
      }
    }
    Assert.assertEquals( "A recurrence type was expected but not found", expectedCount, count );
  }
View Full Code Here

            } else if ( qualifiedDayPattern.matcher( token ).matches() ) {
              String[] days = token.split( "#" ); //$NON-NLS-1$
              dayOfWeekRecurrence
                  .add( new QualifiedDayOfWeek( Integer.parseInt( days[1] ), Integer.parseInt( days[0] ) ) );
            } else if ( lastDayPattern.matcher( token ).matches() ) {
              DayOfWeek dayOfWeek =
                  DayOfWeek.values()[( Integer.parseInt( token.substring( 0, token.length() - 1 ) ) - 1 ) % 7];
              dayOfWeekRecurrence.add( new QualifiedDayOfWeek( DayOfWeekQualifier.LAST, dayOfWeek ) );
            } else if ( dayOfWeekRangePattern.matcher( token ).matches() ) {
              String[] days = token.split( "-" ); //$NON-NLS-1$
              int start = DayOfWeek.valueOf( days[0] ).ordinal();
View Full Code Here

    List<Integer> nonNullRecurrences = ( recurrences == null ? new ArrayList<Integer>() : filterNulls( recurrences ) );
    if ( nonNullRecurrences.size() == 0 ) {
      return;
    }
    if ( nonNullRecurrences.size() == 1 ) {
      theList.add( new RecurrenceList( nonNullRecurrences.get( 0 ) ) );
    } else if ( nonNullRecurrences.size() == 2 ) {
      TreeSet<Integer> sortedRecurrences = new TreeSet<Integer>( nonNullRecurrences );
      theList.add( new RecurrenceList( sortedRecurrences.toArray( new Integer[0] ) ) );
    } else {
      TreeSet<Integer> sortedRecurrences = new TreeSet<Integer>( nonNullRecurrences );
      Integer previourOcurrence = null;
      boolean isSequential = true;
      for ( Integer value : sortedRecurrences ) {
        if ( ( previourOcurrence != null ) && ( value.intValue() != previourOcurrence.intValue() + 1 ) ) {
          isSequential = false;
          break;
        }
        previourOcurrence = value;
      }
      if ( isSequential ) {
        theList.add( new SequentialRecurrence( sortedRecurrences.first(), sortedRecurrences.last() ) );
      } else {
        theList.add( new RecurrenceList( sortedRecurrences.toArray( new Integer[0] ) ) );
      }
    }
  }
View Full Code Here

    String[] tokens = cronExpression.split( delims );
    if ( tokens.length >= 6 ) {
      String dayOfWeekTokens = tokens[5];
      tokens = dayOfWeekTokens.split( "," ); //$NON-NLS-1$
      if ( ( tokens.length > 1 ) || !( tokens[0].equals( "*" ) || tokens[0].equals( "?" ) ) ) { //$NON-NLS-1$ //$NON-NLS-2$
        RecurrenceList dayOfWeekList = null;
        for ( String token : tokens ) {
          if ( listPattern.matcher( token ).matches() ) {
            if ( dayOfWeekList == null ) {
              dayOfWeekList = new RecurrenceList();
            }
            dayOfWeekList.getValues().add( Integer.parseInt( token ) );
          } else {
            if ( dayOfWeekList != null ) {
              dayOfWeekRecurrence.add( dayOfWeekList );
              dayOfWeekList = null;
            }
            if ( sequencePattern.matcher( token ).matches() ) {
              String[] days = token.split( "-" ); //$NON-NLS-1$
              dayOfWeekRecurrence.add( new SequentialRecurrence( Integer.parseInt( days[0] ), Integer
                  .parseInt( days[1] ) ) );
            } else if ( intervalPattern.matcher( token ).matches() ) {
              String[] days = token.split( "/" ); //$NON-NLS-1$
              dayOfWeekRecurrence.add( new IncrementalRecurrence( Integer.parseInt( days[0] ), Integer
                  .parseInt( days[1] ) ) );
            } else if ( qualifiedDayPattern.matcher( token ).matches() ) {
              String[] days = token.split( "#" ); //$NON-NLS-1$
              dayOfWeekRecurrence
                  .add( new QualifiedDayOfWeek( Integer.parseInt( days[1] ), Integer.parseInt( days[0] ) ) );
            } else if ( lastDayPattern.matcher( token ).matches() ) {
              DayOfWeek dayOfWeek =
                  DayOfWeek.values()[( Integer.parseInt( token.substring( 0, token.length() - 1 ) ) - 1 ) % 7];
              dayOfWeekRecurrence.add( new QualifiedDayOfWeek( DayOfWeekQualifier.LAST, dayOfWeek ) );
            } else if ( dayOfWeekRangePattern.matcher( token ).matches() ) {
              String[] days = token.split( "-" ); //$NON-NLS-1$
              int start = DayOfWeek.valueOf( days[0] ).ordinal();
              int finish = DayOfWeek.valueOf( days[1] ).ordinal();
              dayOfWeekRecurrence.add( new SequentialRecurrence( start, finish ) );
            } else {
              dayOfWeekList = new RecurrenceList();
              dayOfWeekList.getValues().add( DayOfWeek.valueOf( token ).ordinal() );
              dayOfWeekRecurrence.add( dayOfWeekList );
              dayOfWeekList = null;
              // } else {
              // throw new IllegalArgumentException(Messages.getInstance().getErrorString(
              //                  "ComplexJobTrigger.ERROR_0001_InvalidCronExpression")); //$NON-NLS-1$
View Full Code Here

    String[] tokens = cronExpression.split( delims );
    if ( tokens.length > tokenIndex ) {
      String timeTokens = tokens[tokenIndex];
      tokens = timeTokens.split( "," ); //$NON-NLS-1$
      if ( ( tokens.length > 1 ) || !( tokens[0].equals( "*" ) || tokens[0].equals( "?" ) ) ) { //$NON-NLS-1$ //$NON-NLS-2$
        RecurrenceList timeList = null;
        for ( String token : tokens ) {
          if ( listPattern.matcher( token ).matches() ) {
            if ( timeList == null ) {
              timeList = new RecurrenceList();
            }
            timeList.getValues().add( Integer.parseInt( token ) );
          } else {
            if ( timeList != null ) {
              timeRecurrence.add( timeList );
              timeList = null;
            }
View Full Code Here

  public void runComplexTriggerTest() throws SchedulerException {
    Calendar calendar = Calendar.getInstance();

    int startingMinute = calendar.get( Calendar.MINUTE );

    RecurrenceList recurrenceList = new RecurrenceList( 40, 45 );
    SequentialRecurrence sequentialRecurrence = new SequentialRecurrence( 40, 45 );
    IncrementalRecurrence incrementalRecurrence = new IncrementalRecurrence( 40, 5 );

    if ( calendar.get( Calendar.SECOND ) > 30 ) {
      recurrenceList = new RecurrenceList( 10, 15 );
      sequentialRecurrence = new SequentialRecurrence( 10, 15 );
      incrementalRecurrence = new IncrementalRecurrence( 10, 5 );
      startingMinute++;
    }
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
View Full Code Here

        Assert.assertEquals( "Wrong first value for dimension " + dimension, seq.getFirstValue(), s.getFirstValue() );
        Assert.assertEquals( "Wrong last value for dimension " + dimension, seq.getLastValue(), s.getLastValue() );
      }
      if ( rec instanceof RecurrenceList ) {
        count++;
        RecurrenceList l = (RecurrenceList) rec;
        Assert.assertEquals( "Wrong first value for dimension " + dimension, list[0], l.getValues().get( 0 ) );
        Assert.assertEquals( "Wrong second value for dimension " + dimension, list[1], l.getValues().get( 1 ) );
      }
      if ( rec instanceof QualifiedDayOfWeek ) {
        count++;
        QualifiedDayOfWeek q = (QualifiedDayOfWeek) rec;
        Assert.assertEquals( "Wrong day of week for dimension " + dimension, qday.getDayOfWeek(), q.getDayOfWeek() );
View Full Code Here

TOP

Related Classes of org.pentaho.platform.scheduler2.quartz.test.ComplexTriggerTest

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.