Skip to content

Commit

Permalink
Issue #64: Fix incorrect next execution time for ranges.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrozanec committed Mar 5, 2016
1 parent b9b9910 commit d3cb14e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ protected List<Integer> generateCandidatesNotIncludingIntervalExtremes(int start
rangestart=expressionStart;
}
try {
if(rangestart!=start){
values.add(rangestart);
}
int reference = generateNextValue(rangestart);
while(reference<rangeend){
values.add(reference);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void testSaturdayExecutionTime(){
DateTime next = executionTime.nextExecution(now);
assertNotEquals(last, next);
}

/**
* Issue: execution time properly calculated
*/
Expand All @@ -189,6 +190,22 @@ public void testWeekdayExecutionTime(){
DateTime next = executionTime.nextExecution(now);
assertNotEquals(last, next);
}

/**
* Issue #64: Incorrect next execution time for ranges
*/
@Test
public void testExecutionTimeForRanges(){
final CronParser quartzParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
ExecutionTime executionTime = ExecutionTime.forCron(quartzParser.parse("* 10-20 * * * * 2099"));
DateTime scanTime = DateTime.parse("2016-02-29T11:00:00.000-06:00");
DateTime nextTime = executionTime.nextExecution(scanTime);
System.out.println(nextTime);
assertNotNull(nextTime);
assertEquals(10, nextTime.getMinuteOfHour());
}


private DateTime truncateToSeconds(DateTime dateTime){
return new DateTime(
dateTime.getYear(),
Expand Down

0 comments on commit d3cb14e

Please sign in to comment.