CronJobManagerImpl implements CronJobManager { @Override public boolean deleteJob(final IJobKey jobKey) { requireNonNull(jobKey); return storage.write(storeProvider -> { if (!storeProvider.getCronJobStore().fetchJob(jobKey).isPresent()) { return false; } removeJob(jobKey, storeProvider.getCronJobStore()); descheduleJob(jobKey); return true; }); } @Inject  CronJobManagerImpl(Storage storage, Scheduler scheduler, TimeZone timeZone); @Override void startJobNow(final IJobKey jobKey); @Override void updateJob(final SanitizedCronJob config); @Override void createJob(final SanitizedCronJob cronJob); @Override boolean deleteJob(final IJobKey jobKey); @Override Map<IJobKey, CrontabEntry> getScheduledJobs();  }
@Test public void testDeleteJob() throws Exception { expect(scheduler.deleteJob(QuartzTestUtil.QUARTZ_JOB_KEY)).andReturn(true); control.replay(); assertFalse(cronJobManager.deleteJob(QuartzTestUtil.AURORA_JOB_KEY)); populateStorage(); assertTrue(cronJobManager.deleteJob(QuartzTestUtil.AURORA_JOB_KEY)); assertEquals(Optional.absent(), fetchFromStorage()); }
@Test public void testFailedDeleteJobDoesNotThrow() throws Exception { expect(scheduler.deleteJob(QuartzTestUtil.QUARTZ_JOB_KEY)).andThrow(new SchedulerException()); control.replay(); populateStorage(); cronJobManager.deleteJob(QuartzTestUtil.AURORA_JOB_KEY); }