use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class CronParserFieldTest method testParse_lastDoWInteger.
@Test
public void testParse_lastDoWInteger() {
cronParserField = new CronParserField(CronFieldName.DAY_OF_WEEK, mockConstraints);
Mockito.when(mockConstraints.getStringMappingValue("1")).thenReturn(null);
final CronField result = cronParserField.parse("1L");
Assert.assertEquals(mockParseResponse, result.getExpression());
Assert.assertEquals(CronFieldName.DAY_OF_WEEK, result.getField());
Mockito.verify(mockConstraints).getStringMappingValue("1");
Mockito.verify(mockParser).parse("1L");
}
use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class CronParserFieldTest method testParse_lastDoWString.
@Test
public void testParse_lastDoWString() {
cronParserField = new CronParserField(CronFieldName.DAY_OF_WEEK, mockConstraints);
Mockito.when(mockConstraints.getStringMappingValue("MON")).thenReturn(1);
final CronField result = cronParserField.parse("MONL");
Assert.assertEquals(mockParseResponse, result.getExpression());
Assert.assertEquals(CronFieldName.DAY_OF_WEEK, result.getField());
Mockito.verify(mockConstraints).getStringMappingValue("MON");
Mockito.verify(mockParser).parse("1L");
}
use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class AndDayOfWeekValueGenerator method generateCandidatesNotIncludingIntervalExtremes.
@Override
protected List<Integer> generateCandidatesNotIncludingIntervalExtremes(final int start, final int end) {
final List<Integer> values = new ArrayList<>();
final And and = (And) cronField.getExpression();
for (final FieldExpression expression : and.getExpressions()) {
final CronField cronField = new CronField(CronFieldName.DAY_OF_WEEK, expression, this.cronField.getConstraints());
final List<Integer> candidatesList = FieldValueGeneratorFactory.createDayOfWeekValueGeneratorInstance(cronField, year, month, mondayDoWValue).generateCandidates(start, end);
// add them to the master list
if (candidatesList != null) {
values.addAll(candidatesList);
}
}
return values;
}
use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class AndFieldValueGenerator method computeCandidates.
private List<Integer> computeCandidates(final Function<FieldValueGenerator, Integer> function) {
final And and = (And) cronField.getExpression();
final List<Integer> candidates = new ArrayList<>();
for (final FieldExpression expression : and.getExpressions()) {
candidates.add(function.apply(createCandidateGeneratorInstance(new CronField(cronField.getField(), expression, cronField.getConstraints()))));
}
final List<Integer> filteredCandidates = new ArrayList<>();
for (final Integer candidate : candidates) {
if (candidate >= 0) {
filteredCandidates.add(candidate);
}
}
Collections.sort(filteredCandidates);
return filteredCandidates;
}
use of com.cronutils.model.field.CronField in project cron-utils by jmrozanec.
the class BetweenDayOfWeekValueGenerator method generateCandidatesNotIncludingIntervalExtremes.
@Override
protected List<Integer> generateCandidatesNotIncludingIntervalExtremes(final int start, final int end) {
final List<Integer> values = new ArrayList<>();
for (Integer dayOfWeek : dowValidValues) {
// Build a CronField representing a single day of the week
final FieldConstraintsBuilder fcb = FieldConstraintsBuilder.instance().forField(CronFieldName.DAY_OF_WEEK);
final CronParserField parser = new CronParserField(CronFieldName.DAY_OF_WEEK, fcb.createConstraintsInstance());
final CronField cronField = parser.parse(dayOfWeek.toString());
// now a generator for matching days
final OnDayOfWeekValueGenerator odow = new OnDayOfWeekValueGenerator(cronField, year, month, mondayDoWValue);
// get the list of matching days
final List<Integer> candidatesList = odow.generateCandidates(start, end);
// add them to the master list
if (candidatesList != null) {
values.addAll(candidatesList);
}
}
Collections.sort(values);
return values;
}
Aggregations