@Test
  public void testMustSchedule_failure() throws Exception {
    final int[] possibleErrors = {
      FirebaseJobDispatcher.SCHEDULE_RESULT_NO_DRIVER_AVAILABLE,
      FirebaseJobDispatcher.SCHEDULE_RESULT_BAD_SERVICE,
      FirebaseJobDispatcher.SCHEDULE_RESULT_UNKNOWN_ERROR,
      FirebaseJobDispatcher.SCHEDULE_RESULT_UNSUPPORTED_TRIGGER
    };

    for (int scheduleError : possibleErrors) {
      when(driver.schedule(null)).thenReturn(scheduleError);

      try {
        dispatcher.mustSchedule(null);

        fail("Expected mustSchedule() with error code " + scheduleError + " to fail");
      } catch (ScheduleFailedException expected) {
        /* expected */
      }
    }

    verify(driver, times(possibleErrors.length)).schedule(null);
  }
Tests for the {@link FirebaseJobDispatcher} class.
jobdispatcher/src/test/java/com/firebase/jobdispatcher/FirebaseJobDispatcherTest.java