Search in sources :

Example 1 with SpecialChar

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

the class FieldValueGeneratorFactoryTest method testForCronFieldOnSpecialCharNotNone.

@Test
public void testForCronFieldOnSpecialCharNotNone() {
    final On mockOn = mock(On.class);
    for (final SpecialChar s : SpecialChar.values()) {
        if (!s.equals(SpecialChar.NONE)) {
            boolean gotException = false;
            when(mockOn.getSpecialChar()).thenReturn(new SpecialCharFieldValue(s));
            when(mockCronField.getExpression()).thenReturn(mockOn);
            try {
                FieldValueGeneratorFactory.forCronField(mockCronField);
            } catch (final RuntimeException e) {
                gotException = true;
            }
            assertTrue("Should get exception when asking for OnValueGenerator with special char", gotException);
        }
    }
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) SpecialChar(com.cronutils.model.field.value.SpecialChar) Test(org.junit.Test)

Example 2 with SpecialChar

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

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

SpecialChar (com.cronutils.model.field.value.SpecialChar)3 SpecialCharFieldValue (com.cronutils.model.field.value.SpecialCharFieldValue)3 Test (org.junit.Test)3 IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)1