JobDispatcher { public void cancel(int jobId) { try { getScheduler().cancel(context, getScheduleId(jobId)); } catch (SchedulerException e) { Logger.error(e, "Scheduler failed to cancel job with id: %s", jobId); if (useFallbackScheduler()) { cancel(jobId); } } } private  JobDispatcher(@NonNull Context context); @VisibleForTesting  JobDispatcher(@NonNull Context context, SchedulerFactory schedulerFactory, ActivityMonitor activityMonitor); @NonNull static JobDispatcher shared(@NonNull Context context); void dispatch(@NonNull JobInfo jobInfo); void cancel(int jobId);  }
@Test public void testCancel() throws SchedulerException { dispatcher.cancel(JobInfo.RICH_PUSH_UPDATE_USER); verify(mockScheduler).cancel(context, 3000007); }
@Test public void testCancelFallback() throws SchedulerException { doThrow(new SchedulerException("test")) .when(mockScheduler) .cancel(context, 3000007); dispatcher.cancel(JobInfo.RICH_PUSH_UPDATE_USER); verify(mockFallbackScheduler).cancel(context, 3000007); }