Search in sources :

Example 11 with IntegerFieldValue

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)));
}
Also used : Every(com.cronutils.model.field.expression.Every) ArrayList(java.util.ArrayList) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) SingleCron(com.cronutils.model.SingleCron) CronField(com.cronutils.model.field.CronField) On(com.cronutils.model.field.expression.On) Test(org.junit.Test)

Example 12 with IntegerFieldValue

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());
}
Also used : WeekDay(com.cronutils.mapper.WeekDay) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 13 with IntegerFieldValue

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());
}
Also used : IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 14 with IntegerFieldValue

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);
}
Also used : IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Example 15 with IntegerFieldValue

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);
}
Also used : IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) Test(org.junit.Test)

Aggregations

IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)43 Test (org.junit.Test)32 CronField (com.cronutils.model.field.CronField)18 SpecialCharFieldValue (com.cronutils.model.field.value.SpecialCharFieldValue)16 On (com.cronutils.model.field.expression.On)13 SingleCron (com.cronutils.model.SingleCron)10 ArrayList (java.util.ArrayList)10 Between (com.cronutils.model.field.expression.Between)6 Before (org.junit.Before)6 WeekDay (com.cronutils.mapper.WeekDay)4 FieldConstraints (com.cronutils.model.field.constraint.FieldConstraints)4 Every (com.cronutils.model.field.expression.Every)3 VisibleForTesting (com.cronutils.utils.VisibleForTesting)3 And (com.cronutils.model.field.expression.And)1 SpecialChar (com.cronutils.model.field.value.SpecialChar)1