FirebaseJobDispatcher { @CancelResult public int cancelAll() { if (!driver.isAvailable()) { return CANCEL_RESULT_NO_DRIVER_AVAILABLE; } return driver.cancelAll(); } FirebaseJobDispatcher(@NonNull Driver driver); @ScheduleResult int schedule(@NonNull Job job); @CancelResult int cancel(@NonNull String tag); @CancelResult int cancelAll(); void mustSchedule(@NonNull Job job); ValidationEnforcer getValidator(); @NonNull Job.Builder newJobBuilder(); RetryStrategy newRetryStrategy(
      @RetryPolicy int policy, int initialBackoff, int maximumBackoff); static final int SCHEDULE_RESULT_SUCCESS; static final int SCHEDULE_RESULT_UNKNOWN_ERROR; static final int SCHEDULE_RESULT_NO_DRIVER_AVAILABLE; static final int SCHEDULE_RESULT_UNSUPPORTED_TRIGGER; static final int SCHEDULE_RESULT_BAD_SERVICE; static final int CANCEL_RESULT_SUCCESS; static final int CANCEL_RESULT_UNKNOWN_ERROR; static final int CANCEL_RESULT_NO_DRIVER_AVAILABLE; }
@Test public void testCancelAllJobs() throws Exception { when(driver.cancelAll()).thenReturn(FirebaseJobDispatcher.CANCEL_RESULT_SUCCESS); assertEquals(FirebaseJobDispatcher.CANCEL_RESULT_SUCCESS, dispatcher.cancelAll()); verify(driver).cancelAll(); }
@Test public void testCancelAllJobs_unavailable() throws Exception { setDriverAvailability(false); assertEquals(FirebaseJobDispatcher.CANCEL_RESULT_NO_DRIVER_AVAILABLE, dispatcher.cancelAll()); verify(driver, never()).cancelAll(); }