### Question:
ReadyService { public Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts) { if (!regCenter.isExisted(ReadyNode.ROOT)) { return Collections.emptyList(); } Collection<String> ineligibleJobNames = Collections2.transform(ineligibleJobContexts, new Function<JobContext, String>() { @Override public String apply(final JobContext input) { return input.getJobConfig().getJobName(); } }); List<String> jobNames = regCenter.getChildrenKeys(ReadyNode.ROOT); List<JobContext> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { if (ineligibleJobNames.contains(each)) { continue; } Optional<CloudJobConfiguration> jobConfig = configService.load(each); if (!jobConfig.isPresent()) { regCenter.remove(ReadyNode.getReadyJobNodePath(each)); continue; } if (!runningService.isJobRunning(each)) { result.add(JobContext.from(jobConfig.get(), ExecutionType.READY)); } } return result; } ReadyService(final CoordinatorRegistryCenter regCenter); void addTransient(final String jobName); void addDaemon(final String jobName); void setMisfireDisabled(final String jobName); Collection<JobContext> getAllEligibleJobContexts(final Collection<JobContext> ineligibleJobContexts); void remove(final Collection<String> jobNames); Map<String, Integer> getAllReadyTasks();  }### Answer:
@Test public void assertGetAllEligibleJobContextsWithoutRootNode() { Mockito.when(regCenter.isExisted("/state/ready")).thenReturn(false); Assert.assertTrue(readyService.getAllEligibleJobContexts(Collections.<JobContext>emptyList()).isEmpty()); Mockito.verify(regCenter).isExisted("/state/ready"); }
@Test public void assertGetAllEligibleJobContextsWithRootNodeAndDaemonJob() { Mockito.when(regCenter.isExisted("/state/ready")).thenReturn(true); Mockito.when(regCenter.getChildrenKeys("/state/ready")).thenReturn(Arrays.asList("not_existed_job", "running_job")); Mockito.when(configService.load("not_existed_job")).thenReturn(Optional.<CloudJobConfiguration>absent()); Mockito.when(configService.load("running_job")).thenReturn(Optional.of(CloudJobConfigurationBuilder.createCloudJobConfiguration("running_job", CloudJobExecutionType.DAEMON))); Mockito.when(runningService.isJobRunning("running_job")).thenReturn(true); Assert.assertThat(readyService.getAllEligibleJobContexts(Collections.<JobContext>emptyList()).size(), Is.is(0)); Mockito.verify(regCenter).isExisted("/state/ready"); Mockito.verify(regCenter, Mockito.times(1)).getChildrenKeys("/state/ready"); Mockito.verify(configService).load("not_existed_job"); Mockito.verify(configService).load("running_job"); }