Search in sources :

Example 16 with ITimeRecurrence

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

the class ComplexTriggerJAXBTest method assertRecurrencesCorrect.

private void assertRecurrencesCorrect(String dimension, int expectedCount, ITimeWrapper recurrences) {
    int count = 0;
    for (ITimeRecurrence rec : recurrences.getRecurrences()) {
        if (rec instanceof IncrementalRecurrence) {
            count++;
            IncrementalRecurrence i = (IncrementalRecurrence) rec;
            Assert.assertEquals("Wrong starting value for dimension " + dimension, inc.getStartingValue(), i.getStartingValue());
            Assert.assertEquals("Wrong increment for dimension " + dimension, inc.getIncrement(), i.getIncrement());
        }
        if (rec instanceof SequentialRecurrence) {
            count++;
            SequentialRecurrence s = (SequentialRecurrence) rec;
            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());
            Assert.assertEquals("Wrong qualifier for dimension " + dimension, qday.getQualifier(), q.getQualifier());
        }
    }
    Assert.assertEquals("A recurrence type was expected but not found", expectedCount, count);
}
Also used : QualifiedDayOfWeek(org.pentaho.platform.scheduler2.recur.QualifiedDayOfWeek) ITimeRecurrence(org.pentaho.platform.api.scheduler2.recur.ITimeRecurrence) IncrementalRecurrence(org.pentaho.platform.scheduler2.recur.IncrementalRecurrence) RecurrenceList(org.pentaho.platform.scheduler2.recur.RecurrenceList) SequentialRecurrence(org.pentaho.platform.scheduler2.recur.SequentialRecurrence)

Aggregations

ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)13 Test (org.junit.Test)12 ITimeRecurrence (org.pentaho.platform.api.scheduler2.recur.ITimeRecurrence)10 RecurrenceList (org.pentaho.platform.scheduler2.recur.RecurrenceList)8 IncrementalRecurrence (org.pentaho.platform.scheduler2.recur.IncrementalRecurrence)7 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)6 Calendar (java.util.Calendar)4 Job (org.pentaho.platform.api.scheduler2.Job)4 QualifiedDayOfWeek (org.pentaho.platform.scheduler2.recur.QualifiedDayOfWeek)4 SequentialRecurrence (org.pentaho.platform.scheduler2.recur.SequentialRecurrence)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Serializable (java.io.Serializable)1 Date (java.util.Date)1 CronJobTrigger (org.pentaho.platform.api.scheduler2.CronJobTrigger)1 QualifiedDayOfMonth (org.pentaho.platform.scheduler2.recur.QualifiedDayOfMonth)1 DayOfWeek (org.pentaho.platform.scheduler2.recur.QualifiedDayOfWeek.DayOfWeek)1 ListParamValue (org.pentaho.platform.scheduler2.ws.ListParamValue)1 MapParamValue (org.pentaho.platform.scheduler2.ws.MapParamValue)1 ParamValue (org.pentaho.platform.scheduler2.ws.ParamValue)1