FirebaseJobDispatcher { @CancelResult public int cancel(@NonNull String tag) { if (!driver.isAvailable()) { return CANCEL_RESULT_NO_DRIVER_AVAILABLE; } return driver.cancel(tag); } 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 testCancelJob() throws Exception { final String tag = "foo"; when(driver.cancel(tag)).thenReturn(FirebaseJobDispatcher.CANCEL_RESULT_SUCCESS); assertEquals( "Expected dispatcher to pass the result of Driver#cancel(String, Class) through", FirebaseJobDispatcher.CANCEL_RESULT_SUCCESS, dispatcher.cancel(tag)); verify(driver).cancel(tag); }
@Test public void testCancelJob_unavailable() throws Exception { setDriverAvailability(false); assertEquals(FirebaseJobDispatcher.CANCEL_RESULT_NO_DRIVER_AVAILABLE, dispatcher.cancel("foo")); verify(driver, never()).cancel("foo"); }