JobScheduleController { public synchronized void pauseJob() { try { if (!scheduler.isShutdown()) { scheduler.pauseAll(); } } catch (final SchedulerException ex) { throw new JobSystemException(ex); } }  void scheduleJob(final String cron); synchronized void rescheduleJob(final String cron); synchronized void rescheduleJob(); synchronized boolean isPaused(); synchronized void pauseJob(); synchronized void resumeJob(); synchronized void triggerJob(); synchronized void shutdown(); synchronized void shutdown(final boolean isCleanShutdown);  }
@Test public void assertPauseJobIfShutdown() throws SchedulerException { when(scheduler.isShutdown()).thenReturn(true); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.pauseJob(); verify(scheduler, times(0)).pauseAll(); }
@Test(expected = JobSystemException.class) public void assertPauseJobFailure() throws SchedulerException { doThrow(SchedulerException.class).when(scheduler).pauseAll(); ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); try { jobScheduleController.pauseJob(); } finally { verify(scheduler).pauseAll(); } }
@Test public void assertPauseJobSuccess() throws SchedulerException { ReflectionUtils.setFieldValue(jobScheduleController, "scheduler", scheduler); jobScheduleController.pauseJob(); verify(scheduler).pauseAll(); }