Search in sources :

Example 6 with Every

use of com.cronutils.model.field.expression.Every 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)

Aggregations

Every (com.cronutils.model.field.expression.Every)6 CronField (com.cronutils.model.field.CronField)3 IntegerFieldValue (com.cronutils.model.field.value.IntegerFieldValue)3 Before (org.junit.Before)2 WeekDay (com.cronutils.mapper.WeekDay)1 SingleCron (com.cronutils.model.SingleCron)1 FieldConstraints (com.cronutils.model.field.constraint.FieldConstraints)1 Between (com.cronutils.model.field.expression.Between)1 On (com.cronutils.model.field.expression.On)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1