DefaultSchedulerService implements SchedulerService { @Override public SchedulerStatus getSchedulerStatus(final String beanName) { final SchedulerStatus status; if (this.applicationContext.containsBean(beanName)) { final Scheduler scheduler = this.applicationContext.getBean(beanName, Scheduler.class); status = scheduler.getSchedulerStatus(); } else { throw new SpringBatchLightminConfigurationException("Could not get status for bean with name: " + beanName); } return status; } DefaultSchedulerService(final BeanRegistrar beanRegistrar,
                                   final JobRepository jobRepository,
                                   final JobRegistry jobRegistry); @Autowired void setApplicationContext(final ApplicationContext applicationContext); @Override String registerSchedulerForJob(final JobConfiguration jobConfiguration); @Override void unregisterSchedulerForJob(final String beanName); @Override void refreshSchedulerForJob(final JobConfiguration jobConfiguration); @Override void schedule(final String beanName, final Boolean forceScheduling); @Override void terminate(final String beanName); @Override SchedulerStatus getSchedulerStatus(final String beanName); @Override void afterPropertiesSet(); @Override JobLauncher createLobLauncher(final TaskExecutorType taskExecutorType, final JobRepository jobRepository);  }
@Test public void getSchedulerStatusTest() { final String beanName = "schedulerBean"; when(this.applicationContext.containsBean(beanName)).thenReturn(Boolean.TRUE); when(this.applicationContext.getBean(beanName, Scheduler.class)).thenReturn(this.scheduler); when(this.scheduler.getSchedulerStatus()).thenReturn(SchedulerStatus.STOPPED); final SchedulerStatus schedulerStatus = this.schedulerService.getSchedulerStatus(beanName); assertThat(schedulerStatus).isEqualTo(SchedulerStatus.STOPPED); }
@Test(expected = SpringBatchLightminConfigurationException.class) public void getSchedulerStatusUnknownTest() { final String beanName = "schedulerBean"; when(this.applicationContext.containsBean(beanName)).thenReturn(Boolean.FALSE); this.schedulerService.getSchedulerStatus(beanName); }