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);
}
}
}
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));
}
}
}
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());
}
Aggregations