FirebaseJobDispatcher { public RetryStrategy newRetryStrategy( @RetryPolicy int policy, int initialBackoff, int maximumBackoff) { return retryStrategyBuilder.build(policy, initialBackoff, maximumBackoff); } 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 testNewRetryStrategyBuilder() { when(validator.validate(any(RetryStrategy.class))) .thenAnswer( new Answer<List<String>>() { @Override public List<String> answer(InvocationOnMock invocation) throws Throwable { RetryStrategy rs = (RetryStrategy) invocation.getArguments()[0]; return rs.getInitialBackoff() == 30 ? null : Arrays.asList("foo", "bar"); } }); try { dispatcher.newRetryStrategy(RetryStrategy.RETRY_POLICY_EXPONENTIAL, 0, 30); fail("Expected initial backoff != 30s to fail using custom validator"); } catch (Exception unused) { } try { dispatcher.newRetryStrategy(RetryStrategy.RETRY_POLICY_EXPONENTIAL, 30, 30); } catch (Exception e) { throw new AssertionError( "Expected initial backoff == 30s not to fail using custom validator", e); } }