JobManager implements ModeChangeListener { public AsyncJobStatus findJob(String jobId) { return this.jobCurator.get(jobId); } @Inject  JobManager(
        Configuration configuration,
        SchedulerFactory schedulerFactory,
        CandlepinModeManager modeManager,
        AsyncJobStatusCurator jobCurator,
        OwnerCurator ownerCurator,
        JobMessageDispatcher dispatcher,
        JobMessageReceiver receiver,
        PrincipalProvider principalProvider,
        CandlepinRequestScope scope,
        Injector injector); static Class<? extends AsyncJob> registerJob(String jobKey, Class<? extends AsyncJob> jobClass); static Class<? extends AsyncJob> unregisterJob(String jobKey); static Class<? extends AsyncJob> getJobClass(String jobKey); synchronized void initialize(); void start(); synchronized void start(Object key); void resume(); void resume(Object key); void suspend(); synchronized void suspend(Object key); synchronized void shutdown(); synchronized ManagerState getManagerState(); boolean isJobEnabled(String jobKey); boolean isSchedulerEnabled(); AsyncJobStatus findJob(String jobId); List<AsyncJobStatus> findJobs(AsyncJobStatusQueryBuilder queryBuilder); @Transactional AsyncJobStatus queueJob(JobConfig config); AsyncJobStatus executeJob(JobMessage message); @Transactional AsyncJobStatus cancelJob(String jobId); @Transactional int cleanupJobs(AsyncJobStatusQueryBuilder queryBuilder); @Transactional int abortNonTerminalJobs(AsyncJobStatusQueryBuilder queryBuilder); @Override void handleModeChange(CandlepinModeManager modeManager, Mode previousMode, Mode currentMode);  }
@Test public void jobStatusFound() { String jobId = "jobId"; Owner owner = new Owner("ownerKey", "owner"); owner.setId("test_owner"); JobManager manager = this.createJobManager(); doReturn(new SystemPrincipal()).when(this.principalProvider).get(); this.injectMockedJobStatus(this.createJobStatus(jobId, owner)); AsyncJobStatus result = manager.findJob(jobId); assertNotNull(result); assertEquals(result.getId(), jobId); }
@Test public void jobStatusFoundWithPermissions() { String jobId = "jobId"; Owner owner = new Owner("ownerKey", "owner"); owner.setId("test_owner"); List<Permission> permissions = Collections .singletonList(new OwnerPermission(owner, Access.READ_ONLY)); JobManager manager = this.createJobManager(); doReturn(new UserPrincipal("user", permissions, false)).when(this.principalProvider).get(); this.injectMockedJobStatus(this.createJobStatus(jobId, owner)); AsyncJobStatus result = manager.findJob(jobId); assertNotNull(result); assertEquals(result.getId(), jobId); }
@Test public void jobStatusNotFound() { String jobId = "jobId"; JobManager manager = this.createJobManager(); assertNull(manager.findJob(jobId)); }