DefaultAdminService implements AdminService { @Override public Collection<JobConfiguration> getJobConfigurationsByJobName(final String jobName) { try { return this.jobConfigurationRepository.getJobConfigurations(jobName, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); } catch (final NoSuchJobException | NoSuchJobConfigurationException e) { final String message = "No Job with name: " + jobName + " is registered"; log.error(message); throw new SpringBatchLightminApplicationException(e, message); } } DefaultAdminService(final JobConfigurationRepository jobConfigurationRepository,
                               final SchedulerService schedulerService,
                               final ListenerService listenerService,
                               final SpringBatchLightminCoreConfigurationProperties springBatchLightminCoreConfigurationProperties
    ); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void saveJobConfiguration(@Valid final JobConfiguration jobConfiguration); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void updateJobConfiguration(final JobConfiguration jobConfiguration); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void deleteJobConfiguration(final Long jobConfigurationId); @Override Collection<JobConfiguration> getJobConfigurationsByJobName(final String jobName); @Override Map<String, Collection<JobConfiguration>> getJobConfigurationMap(final Collection<String> jobNames); @Override Collection<JobConfiguration> getJobConfigurations(final Collection<String> jobNames); @Override JobConfiguration getJobConfigurationById(final Long jobConfigurationId); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void stopJobConfiguration(final Long jobConfigurationId); @Override @Transactional(propagation = Propagation.REQUIRED, transactionManager = "lightminTransactionManager") void startJobConfiguration(final Long jobConfigurationId); @Override void afterPropertiesSet();  }
@Test public void getJobConfigurationsByJobNameTest() { final Long jobConfigurationId = 1L; when(this.properties.getApplicationName()).thenReturn(APPLICATION_NAME); final JobSchedulerConfiguration jobSchedulerConfiguration = DomainTestHelper.createJobSchedulerConfiguration( "0 0/5 * * * ?", null, null, JobSchedulerType.CRON); final JobConfiguration jobConfiguration = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); jobConfiguration.setJobConfigurationId(jobConfigurationId); final Collection<JobConfiguration> jobConfigurations = new LinkedList<>(); jobConfigurations.add(jobConfiguration); try { when(this.jobConfigurationRepository.getJobConfigurations("sampleJob", APPLICATION_NAME)).thenReturn(jobConfigurations); } catch (final NoSuchJobException | NoSuchJobConfigurationException e) { fail(e.getMessage()); } final Collection<JobConfiguration> result = this.defaultAdminService.getJobConfigurationsByJobName("sampleJob"); assertThat(result).hasSize(1); }