ChronosController { public static DateTime calcNextRunTime(final DateTime from, JobSpec job) { String s = job.getCronString(); if (s == null) { s = "* * * * *"; } DateTime toRet = CronExpression.createWithoutSeconds(s) .nextTimeAfter(from); return toRet.withMillisOfSecond(0).withSecondOfMinute(0); } @Autowired  ChronosController(JobDao jobDao, AgentDriver agentDriver, AgentConsumer agentConsumer,
                           ArrayList<SupportedDriver> drivers, String reportRootPath); @ExceptionHandler(Exception.class) @ResponseBody Response internalExceptionHandler(Exception  exception,
    HttpServletRequest request, HttpServletResponse response); @RequestMapping(value="/jobs", method=RequestMethod.GET) @ResponseBody List<JobSpec> getJobs(); @RequestMapping(value="/jobs/history", method=RequestMethod.GET) @ResponseBody List<CallableJob> history(@RequestParam(value="id", required=false) Long id,
          @RequestParam(value="limit", required=true, defaultValue="100") Integer limit); @RequestMapping(value="/jobs/future", method=RequestMethod.GET) @ResponseBody List<FutureRunInfo> future(@RequestParam(value="id", required=false) Long id,
         @RequestParam(value="limit", required=true, defaultValue="100") Integer limit); static DateTime calcNextRunTime(final DateTime from, JobSpec job); void innerJobFuture(List<FutureRunInfo> toRet,
                             DateTime from, List<JobSpec> iterJobs); List<FutureRunInfo> getJobFuture(Long id, int limit); @RequestMapping(value="/job/{id}", method=RequestMethod.GET) @ResponseBody JobSpec getJob(@PathVariable("id") Long id); @RequestMapping(value="/job/{id}/children", method=RequestMethod.GET) @ResponseBody List<JobSpec> getChildren(@PathVariable("id") Long id); @RequestMapping(value="/job/{id}/tree", method=RequestMethod.GET) @ResponseBody JobNode getTree(@PathVariable("id") Long id); @RequestMapping(value="/job/version/{id}", method=RequestMethod.GET) @ResponseBody List<JobSpec> getJobVersions(@PathVariable("id") Long id); @RequestMapping(value="/sources", method=RequestMethod.GET) @ResponseBody ArrayList<SupportedDriver> getDataSources(); static Map<String, Long> assembleIdResp(long id); @RequestMapping(value="/job", method=RequestMethod.POST) @ResponseBody Map<String, Long> createJob(@RequestBody final JobSpec aJob); @RequestMapping(value="/job/{id}", method=RequestMethod.PUT) @ResponseBody Response updateJob(@PathVariable("id") Long id,
      @RequestBody final JobSpec aJob); @RequestMapping(value="/job/{id}", method=RequestMethod.DELETE) @ResponseBody Response deleteJob(@PathVariable("id") Long id); @ResponseBody List<Map<String,String>> getJobResults(
      @RequestParam("id") Long id,
      @RequestParam("limit") int limit); @RequestMapping(value="/running", method=RequestMethod.GET) @ResponseBody List<PlannedJob> getRunning(
      @RequestParam(value="id", required=false) Long id); @RequestMapping(value="/queue", method=RequestMethod.GET) @ResponseBody List<PlannedJob> getQueue(
      @RequestParam(value="id", required=false) Long id); @RequestMapping(value="/queue", method=RequestMethod.POST) @ResponseBody Response queueJob(@RequestBody final PlannedJob aJob); @RequestMapping(value="/queue", method=RequestMethod.DELETE) @ResponseBody Response cancelJob(@RequestBody final PlannedJob aJob); List<String> getReportsList(String root, Long id); @RequestMapping(value="/report-list", method=RequestMethod.GET) @ResponseBody List<String> getReportsList(
    @RequestParam(value="id", required=false) Long id); static Logger LOG; }
@Test public void testJobCalcNextRunTime() throws Exception { JobSpec aJob = getTestJob("Toussaint Louverture"); { DateTime now = new DateTime().withMinuteOfHour(0).withMillisOfSecond(0) .withSecondOfMinute(0); aJob.setCronString("0 * * * *"); DateTime actual = ChronosController.calcNextRunTime(now, aJob); DateTime expected = now.plusHours(1); assertEquals(expected, actual); } { DateTime now = new DateTime().withHourOfDay(0) .withMinuteOfHour(0).withMillisOfSecond(0) .withSecondOfMinute(0); aJob.setCronString("0 0 * * *"); DateTime actual = ChronosController.calcNextRunTime(now, aJob); DateTime expected = now.plusDays(1); assertEquals(expected, actual); } { DateTime now = new DateTime().withHourOfDay(0) .withDayOfWeek(1) .withMinuteOfHour(0).withMillisOfSecond(0) .withSecondOfMinute(0); aJob.setCronString("0 0 * * 1"); DateTime actual = ChronosController.calcNextRunTime(now, aJob); DateTime expected = now.plusDays(7); assertEquals(expected, actual); } { DateTime now = new DateTime().withDayOfMonth(1).withHourOfDay(0) .withMinuteOfHour(0).withMillisOfSecond(0) .withSecondOfMinute(0); aJob.setCronString("0 0 1 * *"); DateTime actual = ChronosController.calcNextRunTime(now, aJob); DateTime expected = now.plusMonths(1) .withDayOfMonth(1); assertEquals(expected, actual); } }