Search in sources :

Example 16 with SpecialCharFieldValue

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

the class OnTest method testAsStringSpecialCharLWithNth.

@Test
public void testAsStringSpecialCharLWithNth() {
    final String expression = "L-3";
    assertEquals(expression, new On(new IntegerFieldValue(-1), new SpecialCharFieldValue(SpecialChar.L), new IntegerFieldValue(3)).asString());
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 17 with SpecialCharFieldValue

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

the class OnTest method testAsStringWithNth.

@Test
public void testAsStringWithNth() {
    final int first = 3;
    final int second = 4;
    final String expression = String.format("%s#%s", first, second);
    assertEquals(expression, new On(new IntegerFieldValue(first), new SpecialCharFieldValue(SpecialChar.HASH), new IntegerFieldValue(second)).asString());
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 18 with SpecialCharFieldValue

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

the class ValidationFieldExpressionVisitorTest method testIsDefault.

@Test
public void testIsDefault() {
    final SpecialCharFieldValue nonIntegerFieldValue = new SpecialCharFieldValue(SpecialChar.LW);
    assertFalse(strictVisitor.isDefault(nonIntegerFieldValue));
    assertFalse(visitor.isDefault(nonIntegerFieldValue));
    IntegerFieldValue integerValue = new IntegerFieldValue(DEFAULT_INT);
    assertTrue(strictVisitor.isDefault(integerValue));
    assertTrue(visitor.isDefault(integerValue));
    integerValue = new IntegerFieldValue(0);
    assertFalse(strictVisitor.isDefault(integerValue));
    assertFalse(visitor.isDefault(integerValue));
    integerValue = new IntegerFieldValue(99);
    assertFalse(strictVisitor.isDefault(integerValue));
    assertFalse(visitor.isDefault(integerValue));
    integerValue = new IntegerFieldValue(-99);
    assertFalse(strictVisitor.isDefault(integerValue));
    assertFalse(visitor.isDefault(integerValue));
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 19 with SpecialCharFieldValue

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

the class ValidationFieldExpressionVisitorTest method testIsSpecialCharNotL.

@Test
public void testIsSpecialCharNotL() {
    SpecialCharFieldValue specialCharFieldValue;
    for (final SpecialChar sp : SpecialChar.values()) {
        specialCharFieldValue = new SpecialCharFieldValue(sp);
        if (sp == SpecialChar.L) {
            assertFalse(strictVisitor.isSpecialCharNotL(specialCharFieldValue));
            assertFalse(visitor.isSpecialCharNotL(specialCharFieldValue));
        } else {
            assertTrue(strictVisitor.isSpecialCharNotL(specialCharFieldValue));
            assertTrue(visitor.isSpecialCharNotL(specialCharFieldValue));
        }
    }
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) SpecialChar(com.cronutils.model.field.value.SpecialChar) Test(org.junit.Test)

Example 20 with SpecialCharFieldValue

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

the class ValidationFieldExpressionVisitorTest method testIsInRange.

@Test
public void testIsInRange() {
    final SpecialCharFieldValue nonIntegerFieldValue = new SpecialCharFieldValue(SpecialChar.LW);
    strictVisitor.isInRange(nonIntegerFieldValue);
    visitor.isInRange(nonIntegerFieldValue);
    final IntegerFieldValue integerValue = new IntegerFieldValue(5);
    strictVisitor.isInRange(integerValue);
    visitor.isInRange(integerValue);
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) 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