use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testVisitBetween.
@Test
public void testVisitBetween() {
Between between = new Between(new IntegerFieldValue(LOW), new IntegerFieldValue(MIDDLE));
assertEquals(between, between.accept(strictVisitor));
assertEquals(between, between.accept(visitor));
between = new Between(new IntegerFieldValue(LOW), new SpecialCharFieldValue(SpecialChar.L));
assertEquals(between, between.accept(strictVisitor));
assertEquals(between, between.accept(visitor));
between = new Between(new SpecialCharFieldValue(SpecialChar.L), new IntegerFieldValue(MIDDLE));
assertEquals(between, between.accept(strictVisitor));
assertEquals(between, between.accept(visitor));
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testVisitAnd.
@Test
public void testVisitAnd() {
final ValidationFieldExpressionVisitor spy = Mockito.spy(visitor);
final ValidationFieldExpressionVisitor strictSpy = Mockito.spy(strictVisitor);
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(HIGH));
final On on = new On(new IntegerFieldValue(LOW));
and.and(b1).and(b2).and(b2).and(on);
assertEquals(and, and.accept(spy));
assertEquals(and, and.accept(strictSpy));
b1.accept(verify(spy, times(1)));
b2.accept(verify(spy, times(2)));
on.accept(verify(spy, times(1)));
b1.accept(verify(strictSpy, times(1)));
b2.accept(verify(strictSpy, times(2)));
on.accept(verify(strictSpy, times(1)));
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testStrictVisitBadExp.
@Test(expected = IllegalArgumentException.class)
public void testStrictVisitBadExp() {
final FieldExpression exp = new Between(new IntegerFieldValue(HIGH), new IntegerFieldValue(LOW));
exp.accept(strictVisitor);
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testVisitBetweenOOOrderNonStrict.
@Test
public void testVisitBetweenOOOrderNonStrict() {
final int startRange = 0;
final int endRange = 59;
fieldConstraints = new FieldConstraints(Collections.emptyMap(), Collections.emptyMap(), Collections.emptySet(), startRange, endRange, false);
visitor = new ValidationFieldExpressionVisitor(fieldConstraints, stringValidations);
final Between between = new Between(new IntegerFieldValue(HIGH), new IntegerFieldValue(LOW));
assertEquals(between, between.accept(visitor));
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class FieldParser method parseOnWithLW.
@VisibleForTesting
protected On parseOnWithLW(final String exp) {
final SpecialCharFieldValue specialChar = new SpecialCharFieldValue(LW);
final String lwExpression = exp.replace(LW_STRING, EMPTY_STRING);
if (EMPTY_STRING.equals(lwExpression)) {
return new On(new IntegerFieldValue(-1), specialChar, new IntegerFieldValue(-1));
} else {
throw new IllegalArgumentException(String.format("Expected: LW, found: %s", lwExpression));
}
}
Aggregations