Search in sources :

Example 21 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue 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 22 with SpecialCharFieldValue

use of com.cronutils.model.field.value.SpecialCharFieldValue 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)

Example 23 with SpecialCharFieldValue

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

the class FieldValueGeneratorFactoryTest method testCreateDayOfMonthValueGeneratorInstanceBadCronFieldName.

@Test(expected = IllegalArgumentException.class)
public void testCreateDayOfMonthValueGeneratorInstanceBadCronFieldName() {
    when(mockCronField.getField()).thenReturn(CronFieldName.YEAR);
    final On mockOn = mock(On.class);
    // any value except NONE
    when(mockOn.getSpecialChar()).thenReturn(new SpecialCharFieldValue(SpecialChar.L));
    when(mockCronField.getExpression()).thenReturn(mockOn);
    FieldValueGeneratorFactory.createDayOfMonthValueGeneratorInstance(mockCronField, 2015, 1);
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) Test(org.junit.Test)

Aggregations

SpecialCharFieldValue (com.cronutils.model.field.value.SpecialCharFieldValue)23 Test (org.junit.Test)17 IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)16 CronField (com.cronutils.model.field.CronField)5 On (com.cronutils.model.field.expression.On)5 SingleCron (com.cronutils.model.SingleCron)4 ArrayList (java.util.ArrayList)4 SpecialChar (com.cronutils.model.field.value.SpecialChar)3 VisibleForTesting (com.cronutils.utils.VisibleForTesting)3 FieldConstraints (com.cronutils.model.field.constraint.FieldConstraints)1 Before (org.junit.Before)1