Search in sources :

Example 6 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class AndFieldValueGeneratorTest method setUp.

@Before
public void setUp() {
    constraints = FieldConstraintsBuilder.instance().createConstraintsInstance();
    fieldValueGenerator = new AndFieldValueGenerator(new CronField(CronFieldName.MONTH, new And().and(new On(new IntegerFieldValue(VALUE0))).and(new On(new IntegerFieldValue(VALUE1))).and(new On(new IntegerFieldValue(VALUE2))), constraints));
}
Also used : And(com.cronutils.model.field.expression.And) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) CronField(com.cronutils.model.field.CronField) On(com.cronutils.model.field.expression.On) Before(org.junit.Before)

Example 7 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class CronDescriptorTest method testLastDayOfMonth.

@Test
public void testLastDayOfMonth() {
    final int hour = 10;
    final int minute = 15;
    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_MONTH, new On(new SpecialCharFieldValue(SpecialChar.L)), nullFieldConstraints));
    assertEquals(String.format("at %s:%s last day of month", hour, minute), descriptor.describe(new SingleCron(mockDefinition, results)));
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) 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 8 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class CronDescriptorTest method testDescribeAtXHours.

@Test
public void testDescribeAtXHours() {
    final int hour = 11;
    final List<CronField> results = new ArrayList<>();
    results.add(new CronField(CronFieldName.HOUR, new On(new IntegerFieldValue(hour)), nullFieldConstraints));
    results.add(new CronField(CronFieldName.MINUTE, FieldExpression.always(), nullFieldConstraints));
    results.add(new CronField(CronFieldName.SECOND, FieldExpression.always(), nullFieldConstraints));
    assertEquals(String.format("at %s:00", hour), descriptor.describe(new SingleCron(mockDefinition, results)));
}
Also used : 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 9 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class CronDescriptorTest method testEveryMinuteBetweenMonths.

@Test
public void testEveryMinuteBetweenMonths() {
    final int monthStart = 2;
    final int monthEnd = 3;
    final List<CronField> results = new ArrayList<>();
    results.add(new CronField(CronFieldName.HOUR, FieldExpression.always(), nullFieldConstraints));
    results.add(new CronField(CronFieldName.MINUTE, FieldExpression.always(), nullFieldConstraints));
    results.add(new CronField(CronFieldName.MONTH, new Between(new IntegerFieldValue(monthStart), new IntegerFieldValue(monthEnd)), nullFieldConstraints));
    assertEquals("every minute every month between February and March", descriptor.describe(new SingleCron(mockDefinition, results)));
}
Also used : Between(com.cronutils.model.field.expression.Between) ArrayList(java.util.ArrayList) IntegerFieldValue(com.cronutils.model.field.value.IntegerFieldValue) SingleCron(com.cronutils.model.SingleCron) CronField(com.cronutils.model.field.CronField) Test(org.junit.Test)

Example 10 with IntegerFieldValue

use of com.cronutils.model.field.value.IntegerFieldValue in project cron-utils by jmrozanec.

the class CronDescriptorTest method testNearestWeekdayToNthOfMonth.

@Test
public void testNearestWeekdayToNthOfMonth() {
    final int dayOfMonth = 22;
    final int hour = 10;
    final int minute = 15;
    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_MONTH, new On(new IntegerFieldValue(dayOfMonth), new SpecialCharFieldValue(SpecialChar.W)), nullFieldConstraints));
    assertEquals(String.format("at %s:%s the nearest weekday to the %s of the month", hour, minute, dayOfMonth), descriptor.describe(new SingleCron(mockDefinition, results)));
}
Also used : SpecialCharFieldValue(com.cronutils.model.field.value.SpecialCharFieldValue) 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)

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