use of com.cronutils.model.field.constraint.FieldConstraints in project cron-utils by jmrozanec.
the class EveryDayOfWeekValueGeneratorTest method setUp.
@Before
public void setUp() {
FieldConstraints constraints = FieldConstraintsBuilder.instance().createConstraintsInstance();
// every 2 days between 1-5
final CronField cronField = new CronField(CronFieldName.DAY_OF_WEEK, new Every(new Between(new IntegerFieldValue(1), new IntegerFieldValue(5)), new IntegerFieldValue(2)), constraints);
// Using monday = 1
WeekDay mondayDoWValue = new WeekDay(1, false);
// so MON-FRI/2, which should translate to MON,WED,FRI
validDow = EnumSet.of(DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY, DayOfWeek.FRIDAY);
fieldValueGenerator = new EveryDayOfWeekValueGenerator(cronField, year, month, mondayDoWValue);
}
use of com.cronutils.model.field.constraint.FieldConstraints in project cron-utils by jmrozanec.
the class OnDayOfMonthValueGeneratorLTest method setUp.
@Before
public void setUp() {
final FieldConstraints constraints = FieldConstraintsBuilder.instance().addLSupport().createConstraintsInstance();
fieldValueGenerator = new OnDayOfMonthValueGenerator(new CronField(CronFieldName.DAY_OF_MONTH, new On(new SpecialCharFieldValue(SpecialChar.L)), constraints), YEAR, MONTH);
}
use of com.cronutils.model.field.constraint.FieldConstraints in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
final int startRange = 0;
final int endRange = 59;
fieldConstraints = new FieldConstraints(Collections.emptyMap(), Collections.emptyMap(), Collections.emptySet(), startRange, endRange, true);
when(stringValidations.removeValidChars(any(String.class))).thenReturn(StringUtils.EMPTY);
when(invalidStringValidations.removeValidChars(any(String.class))).thenReturn("$$$");
strictVisitor = new ValidationFieldExpressionVisitor(fieldConstraints, stringValidations);
visitor = new ValidationFieldExpressionVisitor(fieldConstraints, stringValidations);
}
use of com.cronutils.model.field.constraint.FieldConstraints 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.constraint.FieldConstraints in project cron-utils by jmrozanec.
the class FieldDefinitionBuilderTest method testAnd.
@Test
public void testAnd() {
final FieldConstraints constraints = mock(FieldConstraints.class);
when(mockConstraintsBuilder.createConstraintsInstance()).thenReturn(constraints);
final ArgumentCaptor<FieldDefinition> argument = ArgumentCaptor.forClass(FieldDefinition.class);
fieldDefinitionBuilder.and();
verify(mockParserBuilder).register(argument.capture());
assertEquals(testFieldName, argument.getValue().getFieldName());
verify(mockConstraintsBuilder).createConstraintsInstance();
}
Aggregations