Search in sources :

Example 41 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class ValidationFieldExpressionVisitorTest method testVisitOn.

@Test
public void testVisitOn() {
    On on = new On(new IntegerFieldValue(LOW));
    assertEquals(on, on.accept(strictVisitor));
    assertEquals(on, on.accept(visitor));
    on = new On(new IntegerFieldValue(DEFAULT_INT));
    assertEquals(on, on.accept(strictVisitor));
    assertEquals(on, on.accept(visitor));
    on = new On(new SpecialCharFieldValue(SpecialChar.L));
    assertEquals(on, on.accept(strictVisitor));
    assertEquals(on, on.accept(visitor));
    on = new On(new IntegerFieldValue(LOW), new SpecialCharFieldValue(SpecialChar.L), new IntegerFieldValue(HIGH));
    assertEquals(on, on.accept(strictVisitor));
    assertEquals(on, on.accept(visitor));
    on = new On(new IntegerFieldValue(LOW), new SpecialCharFieldValue(SpecialChar.LW), new IntegerFieldValue(DEFAULT_INT));
    assertEquals(on, on.accept(strictVisitor));
    assertEquals(on, on.accept(visitor));
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 42 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class ValidationFieldExpressionVisitorTest method testStrictVisitAndBadExpression.

@Test(expected = IllegalArgumentException.class)
public void testStrictVisitAndBadExpression() {
    final And and = new And();
    final Between b1 = new Between(new IntegerFieldValue(LOW), new IntegerFieldValue(MIDDLE));
    final Between b2 = new Between(new IntegerFieldValue(MIDDLE), new IntegerFieldValue(HIGHOOR));
    final On on = new On(new IntegerFieldValue(LOW));
    and.and(b1).and(b2).and(b2).and(on);
    and.accept(strictVisitor);
}
Also used : IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 43 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class BetweenTest method testNonNumericRangeSupported.

@Test
public void testNonNumericRangeSupported() {
    final SpecialChar specialChar = SpecialChar.L;
    final Between between = new Between(new SpecialCharFieldValue(specialChar), new IntegerFieldValue(to));
    assertEquals(specialChar, between.getFrom().getValue());
    assertEquals(to, between.getTo().getValue());
    assertEquals(String.format("%s-%s", specialChar, to), between.asString());
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) SpecialChar(com.cronutils.model.field.value.SpecialChar) Test(org.junit.Test)

Aggregations

IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)43 Test (org.junit.Test)32 CronField (com.cronutils.model.field.CronField)18 SpecialCharFieldValue (com.cronutils.model.field.value.SpecialCharFieldValue)16 On (com.cronutils.model.field.expression.On)13 SingleCron (com.cronutils.model.SingleCron)10 ArrayList (java.util.ArrayList)10 Between (com.cronutils.model.field.expression.Between)6 Before (org.junit.Before)6 WeekDay (com.cronutils.mapper.WeekDay)4 FieldConstraints (com.cronutils.model.field.constraint.FieldConstraints)4 Every (com.cronutils.model.field.expression.Every)3 VisibleForTesting (com.cronutils.utils.VisibleForTesting)3 And (com.cronutils.model.field.expression.And)1 SpecialChar (com.cronutils.model.field.value.SpecialChar)1