Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ object JobUtils {
protected def calculateSkips(dateTime: DateTime, jobStart: DateTime, period: Period): Int = {
// If the period is at least a month, we have to actually add the period to the date
// until it's in the future because a month-long period might have different seconds
if (period.getMonths >= 1) {
if (period.getMonths >= 1 || period.getYears >= 1) {
var skips = 0
var newDate = new DateTime(jobStart)
while (newDate.isBefore(dateTime)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ class JobUtilsSpec extends SpecificationWithJUnit with Mockito {
scheduledTime.dayOfMonth().get must_== 1
}

"Can skip forward a job with a yearly period" in {
val schedule = s"R/2012-01-01T00:00:01.000Z/P1Y"
val job = new ScheduleBasedJob(schedule, "sample-name", "sample-command")
val now = new DateTime()

// Get the schedule stream, which should have been skipped forward
val stream = JobUtils.skipForward(job, now)
val scheduledTime = Iso8601Expressions.parse(stream.get.schedule, job.scheduleTimeZone).get._2

// Ensure that this job runs on the first of next month
scheduledTime.isAfter(now) must beTrue
scheduledTime.dayOfMonth().get must_== 1
}

"Can get job with arguments" in {
val schedule = "R/2012-01-01T00:00:01.000Z/P1M"
val arguments = "--help"
Expand Down