DefaultAdminService implements AdminService { @Override public Map<String, Collection<JobConfiguration>> getJobConfigurationMap(final Collection<String> jobNames) { final Map<String, Collection<JobConfiguration>> jobConfigurationMap = new HashMap<>(); final Collection<JobConfiguration> jobConfigurations = this.jobConfigurationRepository.getAllJobConfigurationsByJobNames(jobNames, this.springBatchLightminCoreConfigurationProperties.getApplicationName()); this.attachSchedulerStatus(jobConfigurations); log.info("Fetched " + jobConfigurations.size() + " JobConfigurations"); for (final JobConfiguration jobConfiguration : jobConfigurations) { final String jobName = jobConfiguration.getJobName(); if (!jobConfigurationMap.containsKey(jobName)) { jobConfigurationMap.put(jobName, new HashSet<>()); } log.info("add " + jobConfiguration + " to result set"); jobConfigurationMap.get(jobName).add(jobConfiguration); } return jobConfigurationMap; } 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 getJobConfigurationMapTest() { 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(1L); final JobConfiguration jobConfigurationSecond = DomainTestHelper.createJobConfiguration(jobSchedulerConfiguration); jobConfigurationSecond.setJobConfigurationId(2L); final Collection<JobConfiguration> jobConfigurations = new LinkedList<>(); jobConfigurations.add(jobConfiguration); jobConfigurations.add(jobConfigurationSecond); final Collection<String> jobNames = new LinkedList<>(); jobNames.add("sampleJob"); when(this.jobConfigurationRepository.getAllJobConfigurationsByJobNames(jobNames, APPLICATION_NAME)).thenReturn(jobConfigurations); final Map<String, Collection<JobConfiguration>> result = this.defaultAdminService.getJobConfigurationMap(jobNames); assertThat(result).containsKey("sampleJob"); assertThat(result.get("sampleJob")).hasSize(2); }