@Test public void getRandomizedBackoffDuration_callOverMaxTimes_returnsUpToMaxInterval() throws Exception { int backoffDurationsLength = BACKOFF_TIME_DURATIONS_IN_MINUTES.length; for (int numFetch = 1; numFetch <= backoffDurationsLength + 2; numFetch++) { long backoffDurationInterval = MINUTES.toMillis( BACKOFF_TIME_DURATIONS_IN_MINUTES[Math.min(numFetch, backoffDurationsLength) - 1]); fetchCallToBackendThrowsException(HTTP_TOO_MANY_REQUESTS); when(mockRandom.nextInt((int) backoffDurationInterval)) .thenReturn(new Random().nextInt((int) backoffDurationInterval)); FirebaseRemoteConfigFetchThrottledException actualException = getThrottledException(fetchHandler.fetch( 0L)); long actualBackoffDuration = actualException.getThrottleEndTimeMillis() - mockClock.currentTimeMillis(); assertThat(actualBackoffDuration) .isAtLeast(backoffDurationInterval - backoffDurationInterval / 2); assertThat(actualBackoffDuration) .isLessThan(backoffDurationInterval + backoffDurationInterval / 2); mockClock.advance(actualBackoffDuration); } }
public Task<FetchResponse> fetch() { return fetch(frcMetadata.getMinimumFetchIntervalInSeconds()); }
ConfigFetchHandler { public Task<FetchResponse> fetch() { return fetch(frcMetadata.getMinimumFetchIntervalInSeconds()); } }
ConfigFetchHandler { public Task<FetchResponse> fetch() { return fetch(frcMetadata.getMinimumFetchIntervalInSeconds()); } ConfigFetchHandler(
      FirebaseInstallationsApi firebaseInstallations,
      @Nullable AnalyticsConnector analyticsConnector,
      Executor executor,
      Clock clock,
      Random randomGenerator,
      ConfigCacheClient fetchedConfigsCache,
      ConfigFetchHttpClient frcBackendApiClient,
      ConfigMetadataClient frcMetadata,
      Map<String, String> customHttpHeaders); }
ConfigFetchHandler { public Task<FetchResponse> fetch() { return fetch(frcMetadata.getMinimumFetchIntervalInSeconds()); } ConfigFetchHandler(
      FirebaseInstallationsApi firebaseInstallations,
      @Nullable AnalyticsConnector analyticsConnector,
      Executor executor,
      Clock clock,
      Random randomGenerator,
      ConfigCacheClient fetchedConfigsCache,
      ConfigFetchHttpClient frcBackendApiClient,
      ConfigMetadataClient frcMetadata,
      Map<String, String> customHttpHeaders); Task<FetchResponse> fetch(); Task<FetchResponse> fetch(long minimumFetchIntervalInSeconds); @VisibleForTesting @Nullable AnalyticsConnector getAnalyticsConnector(); }
ConfigFetchHandler { public Task<FetchResponse> fetch() { return fetch(frcMetadata.getMinimumFetchIntervalInSeconds()); } ConfigFetchHandler(
      FirebaseInstallationsApi firebaseInstallations,
      @Nullable AnalyticsConnector analyticsConnector,
      Executor executor,
      Clock clock,
      Random randomGenerator,
      ConfigCacheClient fetchedConfigsCache,
      ConfigFetchHttpClient frcBackendApiClient,
      ConfigMetadataClient frcMetadata,
      Map<String, String> customHttpHeaders); Task<FetchResponse> fetch(); Task<FetchResponse> fetch(long minimumFetchIntervalInSeconds); @VisibleForTesting @Nullable AnalyticsConnector getAnalyticsConnector(); static final long DEFAULT_MINIMUM_FETCH_INTERVAL_IN_SECONDS; }