DefaultJobService implements JobService { @Override public Job getJobByName(final String jobName) { Job job; try { job = this.jobRegistry.getJob(jobName); } catch (final NoSuchJobException e) { log.info("Could not find job with jobName: " + jobName); job = null; } return job; } DefaultJobService(final JobOperator jobOperator,
                             final JobRegistry jobRegistry,
                             final JobExplorer jobExplorer,
                             final LightminJobExecutionDao lightminJobExecutionDao); @Override int getJobInstanceCount(final String jobName); @Override int getJobExecutionCount(final JobInstance jobInstance); @Override Set<String> getJobNames(); @Override Job getJobByName(final String jobName); @Override Collection<JobInstance> getJobInstances(final String jobName, final int startIndex, final int pageSize); @Override Collection<JobExecution> getJobExecutions(final JobInstance jobInstance); @Override Collection<JobExecution> getJobExecutions(final JobInstance jobInstance, final int start, final int count); @Override JobExecution getJobExecution(final Long jobExecutionId); @Override JobInstance getJobInstance(final Long jobInstanceId); @Override void attachJobInstance(final JobExecution jobExecution); @Override void restartJobExecution(final Long jobExecutionId); @Override void stopJobExecution(final Long jobExecutionId); @Override JobParameters getLastJobParameters(final String jobName); @Override void afterPropertiesSet();  }
@Test public void getJobByNameTest() throws NoSuchJobException { final Job expectedJob = DomainTestHelper.createJob(JOB_NAME); when(this.jobRegistry.getJob(JOB_NAME)).thenReturn(expectedJob); final Job job = this.jobService.getJobByName(JOB_NAME); assertThat(job).isEqualTo(expectedJob); }
@Test public void getJobByNameNoSuchJobExecptionTest() throws NoSuchJobException { when(this.jobRegistry.getJob(JOB_NAME)).thenThrow(new NoSuchJobException("TEST")); final Job job = this.jobService.getJobByName(JOB_NAME); assertThat(job).isNull(); }