DefaultAdminService implements AdminService { @Override public JobConfiguration getJobConfigurationById(final Long jobConfigurationId) { try { final JobConfiguration jobConfiguration = this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.attachSchedulerStatus(jobConfiguration); return jobConfiguration; } catch (final NoSuchJobConfigurationException e) { throw new SpringBatchLightminApplicationException(e, e.getMessage()); } } 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 getJobConfigurationByIdTest() { 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); try { when(this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, APPLICATION_NAME)).thenReturn(jobConfiguration); } catch (final NoSuchJobConfigurationException e) { fail(e.getMessage()); } final JobConfiguration result = this.defaultAdminService.getJobConfigurationById(jobConfigurationId); assertThat(result).isEqualTo(jobConfiguration); }
@SuppressWarnings("unchecked") @Test(expected = SpringBatchLightminApplicationException.class) public void getJobConfigurationByIdErrorTest() { final Long jobConfigurationId = 1L; when(this.properties.getApplicationName()).thenReturn(APPLICATION_NAME); try { when(this.jobConfigurationRepository.getJobConfiguration(jobConfigurationId, APPLICATION_NAME)) .thenThrow(NoSuchJobConfigurationException.class); } catch (final NoSuchJobConfigurationException e) { fail(e.getMessage()); } this.defaultAdminService.getJobConfigurationById(jobConfigurationId); }