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)));
}
Aggregations