use of com.cronutils.model.field.expression.Between in project cron-utils by jmrozanec.
the class CronDescriptorTest method testDescribeEveryXMinutesBetweenTime.
@Test
public void testDescribeEveryXMinutesBetweenTime() {
final int hour = 11;
final int start = 0;
final int end = 10;
final Between expression = new Between(new IntegerFieldValue(start), new IntegerFieldValue(end));
final List<CronField> results = new ArrayList<>();
results.add(new CronField(CronFieldName.MINUTE, expression, nullFieldConstraints));
results.add(new CronField(CronFieldName.HOUR, new On(new IntegerFieldValue(hour)), nullFieldConstraints));
assertEquals(String.format("every minute between %s:%02d and %s:%02d", hour, start, hour, end), descriptor.describe(new SingleCron(mockDefinition, results)));
}
use of com.cronutils.model.field.expression.Between in project cron-utils by jmrozanec.
the class CronDescriptorTest method testDescribeAtXTimeBetweenDaysOfWeek.
@Test
public void testDescribeAtXTimeBetweenDaysOfWeek() {
final int hour = 11;
final int minute = 30;
final int start = 2;
final int end = 6;
final Between expression = new Between(new IntegerFieldValue(start), new IntegerFieldValue(end));
final List<CronField> results = new ArrayList<>();
results.add(new CronField(CronFieldName.HOUR, new On(new IntegerFieldValue(hour)), nullFieldConstraints));
results.add(new CronField(CronFieldName.MINUTE, new On(new IntegerFieldValue(minute)), nullFieldConstraints));
results.add(new CronField(CronFieldName.DAY_OF_WEEK, expression, nullFieldConstraints));
assertEquals(String.format("at %s:%s every day between Tuesday and Saturday", hour, minute), descriptor.describe(new SingleCron(mockDefinition, results)));
}
use of com.cronutils.model.field.expression.Between in project cron-utils by jmrozanec.
the class BetweenDayOfWeekValueGeneratorTest method testGenerateCandidatesNotIncludingIntervalExtremes.
@Test
public void testGenerateCandidatesNotIncludingIntervalExtremes() {
// cron expression: DoW 1-5,
// on February 2016: 1-5, 8-12, 15-19, 22-26, 29
final CronField cronField = new CronField(CronFieldName.DAY_OF_WEEK, new Between(new IntegerFieldValue(1), new IntegerFieldValue(5)), FieldConstraintsBuilder.instance().createConstraintsInstance());
final BetweenDayOfWeekValueGenerator generator = new BetweenDayOfWeekValueGenerator(cronField, 2016, 2, new WeekDay(1, true));
final List<Integer> values = generator.generateCandidates(1, 29);
validateInterval(1, 5, values);
validateInterval(8, 12, values);
validateInterval(15, 19, values);
validateInterval(22, 26, values);
assertTrue(values.contains(29));
}
use of com.cronutils.model.field.expression.Between in project cron-utils by jmrozanec.
the class BetweenFieldValueGeneratorTest method setUp.
@Before
public void setUp() {
constraints = FieldConstraintsBuilder.instance().createConstraintsInstance();
fieldValueGenerator = new BetweenFieldValueGenerator(new CronField(CronFieldName.HOUR, new Between(new IntegerFieldValue(FROM), new IntegerFieldValue(TO)), constraints));
}
Aggregations