use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class CronDescriptorTest method testDescribeEveryXTimeUnits.
@Test
public void testDescribeEveryXTimeUnits() {
final int time = 3;
final Every expression = new Every(new IntegerFieldValue(time));
assertEquals(String.format("every %s seconds", time), descriptor.describe(new SingleCron(mockDefinition, Collections.singletonList(new CronField(CronFieldName.SECOND, expression, nullFieldConstraints)))));
assertEquals(String.format("every %s minutes", time), descriptor.describe(new SingleCron(mockDefinition, Collections.singletonList(new CronField(CronFieldName.MINUTE, expression, nullFieldConstraints)))));
final List<CronField> params = new ArrayList<>();
params.add(new CronField(CronFieldName.HOUR, expression, nullFieldConstraints));
params.add(new CronField(CronFieldName.MINUTE, new On(new IntegerFieldValue(time)), nullFieldConstraints));
assertEquals(String.format("every %s hours at minute %s", time, time), descriptor.describe(new SingleCron(mockDefinition, params)));
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class FieldValueGeneratorFactoryTest method testCreateDayOfWeekValueGeneratorInstanceBetween.
@Test
public void testCreateDayOfWeekValueGeneratorInstanceBetween() {
final Between between = new Between(new IntegerFieldValue(1), new IntegerFieldValue(7));
when(mockCronField.getField()).thenReturn(CronFieldName.DAY_OF_WEEK);
when(mockCronField.getExpression()).thenReturn(between);
assertEquals(BetweenDayOfWeekValueGenerator.class, FieldValueGeneratorFactory.createDayOfWeekValueGeneratorInstance(mockCronField, 2015, 1, new WeekDay(1, false)).getClass());
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class EveryTest method testGetTime.
@Test
public void testGetTime() {
final int every = 5;
assertEquals(every, (int) new Every(new IntegerFieldValue(every)).getPeriod().getValue());
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testVisitBadExp.
@Test(expected = IllegalArgumentException.class)
public void testVisitBadExp() {
final FieldExpression exp = new Between(new IntegerFieldValue(LOWOOR), new IntegerFieldValue(HIGH));
exp.accept(visitor);
}
use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testIsInRangeOORangeStrict.
@Test(expected = IllegalArgumentException.class)
public void testIsInRangeOORangeStrict() {
final IntegerFieldValue integerValue = new IntegerFieldValue(HIGHOOR);
strictVisitor.isInRange(integerValue);
}
Aggregations