use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.
the class ValidationFieldExpressionVisitorTest method testVisitBetween.
@Test
public void testVisitBetween() {
Between between = new Between(new IntegerFieldValue(LOW), new IntegerFieldValue(MIDDLE));
assertEquals(between, between.accept(strictVisitor));
assertEquals(between, between.accept(visitor));
between = new Between(new IntegerFieldValue(LOW), new SpecialCharFieldValue(SpecialChar.L));
assertEquals(between, between.accept(strictVisitor));
assertEquals(between, between.accept(visitor));
between = new Between(new SpecialCharFieldValue(SpecialChar.L), new IntegerFieldValue(MIDDLE));
assertEquals(between, between.accept(strictVisitor));
assertEquals(between, between.accept(visitor));
}
use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.
the class FieldParser method parseOnWithLW.
@VisibleForTesting
protected On parseOnWithLW(final String exp) {
final SpecialCharFieldValue specialChar = new SpecialCharFieldValue(LW);
final String lwExpression = exp.replace(LW_STRING, EMPTY_STRING);
if (EMPTY_STRING.equals(lwExpression)) {
return new On(new IntegerFieldValue(-1), specialChar, new IntegerFieldValue(-1));
} else {
throw new IllegalArgumentException(String.format("Expected: LW, found: %s", lwExpression));
}
}
use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.
the class CronDescriptorTest method testNthDayOfWeekInMonth.
@Test
public void testNthDayOfWeekInMonth() {
final int dayOfWeek = 2;
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_WEEK, new On(new IntegerFieldValue(dayOfWeek), new SpecialCharFieldValue(SpecialChar.HASH), new IntegerFieldValue(dayOfWeek)), nullFieldConstraints));
assertEquals(String.format("at %s:%s Tuesday %s of every month", hour, minute, dayOfWeek), descriptor.describe(new SingleCron(mockDefinition, results)));
}
use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.
the class CronDescriptorTest method testLastDayOfWeekInMonth.
@Test
public void testLastDayOfWeekInMonth() {
final int dayOfWeek = 2;
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_WEEK, new On(new IntegerFieldValue(dayOfWeek), new SpecialCharFieldValue(SpecialChar.L)), nullFieldConstraints));
assertEquals(String.format("at %s:%s last Tuesday of every month", hour, minute), descriptor.describe(new SingleCron(mockDefinition, results)));
}
use of com.cronutils.model.field.value.SpecialCharFieldValue in project cron-utils by jmrozanec.
the class OnTest method testAsStringSpecialCharW.
@Test
public void testAsStringSpecialCharW() {
final String expression = "1W";
assertEquals(expression, new On(new IntegerFieldValue(1), new SpecialCharFieldValue(SpecialChar.W)).asString());
}
Aggregations