use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class OnDayOfWeekValueGeneratorTest method setUp.
@Before
public void setUp() {
constraints = FieldConstraintsBuilder.instance().createConstraintsInstance();
mondayDoWValue = new WeekDay(1, false);
fieldValueGenerator = new OnDayOfWeekValueGenerator(new CronField(CronFieldName.DAY_OF_WEEK, new On(new IntegerFieldValue(3)), constraints), YEAR, MONTH, mondayDoWValue);
}
use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class CronParserFieldTest method testParse.
@Test
public void testParse() {
final String cron = UUID.randomUUID().toString();
final CronField result = cronParserField.parse(cron);
Assert.assertEquals(mockParseResponse, result.getExpression());
Assert.assertEquals(testFieldName, result.getField());
Mockito.verify(mockParser).parse(cron);
}
use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class CronMapperTest method testReturnOnZeroExpression.
@Test
public void testReturnOnZeroExpression() {
final Function<CronField, CronField> function = CronMapper.returnOnZeroExpression(testCronFieldName);
assertEquals(testCronFieldName, function.apply(mockCronField).getField());
final On result = (On) function.apply(mockCronField).getExpression();
assertEquals(0, (int) result.getTime().getValue());
}
use of com.cronutils.model.field.CronField in project dolphinscheduler by apache.
the class CronUtilsTest method test2.
/**
* test
*/
@Test
public void test2() {
Cron cron1 = CronBuilder.cron(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ)).withYear(always()).withDoW(questionMark()).withMonth(always()).withDoM(always()).withHour(always()).withMinute(every(5)).withSecond(on(0)).instance();
// minute cycle
String[] cronArayy = new String[] { "* * * * * ? *", "* 0 * * * ? *", "* 5 * * 3/5 ? *", "0 0 * * * ? *" };
for (String minCrontab : cronArayy) {
if (!org.quartz.CronExpression.isValidExpression(minCrontab)) {
throw new RuntimeException(minCrontab + " verify failure, cron expression not valid");
}
Cron cron = CronUtils.parse2Cron(minCrontab);
CronField minField = cron.retrieve(CronFieldName.MINUTE);
logger.info("minField instanceof Between:" + (minField.getExpression() instanceof Between));
logger.info("minField instanceof Every:" + (minField.getExpression() instanceof Every));
logger.info("minField instanceof Always:" + (minField.getExpression() instanceof Always));
logger.info("minField instanceof On:" + (minField.getExpression() instanceof On));
logger.info("minField instanceof And:" + (minField.getExpression() instanceof And));
CronField hourField = cron.retrieve(CronFieldName.HOUR);
logger.info("hourField instanceof Between:" + (hourField.getExpression() instanceof Between));
logger.info("hourField instanceof Always:" + (hourField.getExpression() instanceof Always));
logger.info("hourField instanceof Every:" + (hourField.getExpression() instanceof Every));
logger.info("hourField instanceof On:" + (hourField.getExpression() instanceof On));
logger.info("hourField instanceof And:" + (hourField.getExpression() instanceof And));
CronField dayOfMonthField = cron.retrieve(CronFieldName.DAY_OF_MONTH);
logger.info("dayOfMonthField instanceof Between:" + (dayOfMonthField.getExpression() instanceof Between));
logger.info("dayOfMonthField instanceof Always:" + (dayOfMonthField.getExpression() instanceof Always));
logger.info("dayOfMonthField instanceof Every:" + (dayOfMonthField.getExpression() instanceof Every));
logger.info("dayOfMonthField instanceof On:" + (dayOfMonthField.getExpression() instanceof On));
logger.info("dayOfMonthField instanceof And:" + (dayOfMonthField.getExpression() instanceof And));
logger.info("dayOfMonthField instanceof QuestionMark:" + (dayOfMonthField.getExpression() instanceof QuestionMark));
CronField monthField = cron.retrieve(CronFieldName.MONTH);
logger.info("monthField instanceof Between:" + (monthField.getExpression() instanceof Between));
logger.info("monthField instanceof Always:" + (monthField.getExpression() instanceof Always));
logger.info("monthField instanceof Every:" + (monthField.getExpression() instanceof Every));
logger.info("monthField instanceof On:" + (monthField.getExpression() instanceof On));
logger.info("monthField instanceof And:" + (monthField.getExpression() instanceof And));
logger.info("monthField instanceof QuestionMark:" + (monthField.getExpression() instanceof QuestionMark));
CronField dayOfWeekField = cron.retrieve(CronFieldName.DAY_OF_WEEK);
logger.info("dayOfWeekField instanceof Between:" + (dayOfWeekField.getExpression() instanceof Between));
logger.info("dayOfWeekField instanceof Always:" + (dayOfWeekField.getExpression() instanceof Always));
logger.info("dayOfWeekField instanceof Every:" + (dayOfWeekField.getExpression() instanceof Every));
logger.info("dayOfWeekField instanceof On:" + (dayOfWeekField.getExpression() instanceof On));
logger.info("dayOfWeekField instanceof And:" + (dayOfWeekField.getExpression() instanceof And));
logger.info("dayOfWeekField instanceof QuestionMark:" + (dayOfWeekField.getExpression() instanceof QuestionMark));
CycleEnum cycleEnum = CronUtils.getMaxCycle(minCrontab);
if (cycleEnum != null) {
logger.info(cycleEnum.name());
} else {
logger.info("can't get scheduleType");
}
}
Assert.assertTrue(true);
}
Aggregations