Skip to content

Commit 3b9ed42

Browse files
committed
Formating and naming.
1 parent 01262b4 commit 3b9ed42

File tree

7 files changed

+30
-33
lines changed

7 files changed

+30
-33
lines changed

firebase-config/src/main/java/com/google/firebase/remoteconfig/RemoteConfigComponent.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ synchronized ConfigRealtimeHandler getRealtime(
285285
activatedCacheClient,
286286
context,
287287
namespace,
288-
scheduledExecutorService
289-
);
288+
scheduledExecutorService);
290289
}
291290

292291
private ConfigGetParameterHandler getGetHandler(

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigAutoFetch.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.util.HashSet;
3434
import java.util.Random;
3535
import java.util.Set;
36-
import java.util.concurrent.ExecutorService;
3736
import java.util.concurrent.ScheduledExecutorService;
3837
import java.util.concurrent.TimeUnit;
3938
import org.json.JSONException;
@@ -207,7 +206,7 @@ public synchronized Task<Void> fetchLatestConfig(int remainingAttempts, long tar
207206

208207
return Tasks.whenAllComplete(fetchTask, activatedConfigsTask)
209208
.continueWithTask(
210-
executorService,
209+
executorService,
211210
(listOfUnusedCompletedTasks) -> {
212211
if (!fetchTask.isSuccessful()) {
213212
return Tasks.forException(

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private synchronized void beginRealtime() {
9797
context,
9898
namespace,
9999
listeners,
100-
scheduledExecutorService);
100+
scheduledExecutorService);
101101
this.realtimeHttpClientTask =
102102
this.scheduledExecutorService.submit(
103103
new RealtimeHttpClientFutureTask(

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,12 @@ public void onError(@NonNull FirebaseRemoteConfigException error) {
307307
};
308308

309309
return new ConfigAutoFetch(
310-
httpURLConnection, configFetchHandler, activatedCache, listeners, retryCallback, scheduledExecutorService);
310+
httpURLConnection,
311+
configFetchHandler,
312+
activatedCache,
313+
listeners,
314+
retryCallback,
315+
scheduledExecutorService);
311316
}
312317

313318
// HTTP status code that the Realtime client should retry on.

firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
package com.google.firebase.remoteconfig;
1616

17-
import static android.os.AsyncTask.THREAD_POOL_EXECUTOR;
1817
import static androidx.test.ext.truth.os.BundleSubject.assertThat;
1918
import static com.google.common.truth.Truth.assertThat;
2019
import static com.google.common.truth.Truth.assertWithMessage;
@@ -44,7 +43,6 @@
4443

4544
import android.content.Context;
4645
import android.content.res.Resources;
47-
import android.os.AsyncTask;
4846
import android.os.Bundle;
4947
import androidx.annotation.NonNull;
5048
import androidx.test.core.app.ApplicationProvider;
@@ -86,14 +84,11 @@
8684
import java.util.List;
8785
import java.util.Map;
8886
import java.util.Set;
89-
import java.util.concurrent.Callable;
9087
import java.util.concurrent.CountDownLatch;
9188
import java.util.concurrent.Executor;
92-
import java.util.concurrent.ExecutorService;
9389
import java.util.concurrent.Executors;
9490
import java.util.concurrent.ScheduledExecutorService;
9591
import java.util.concurrent.TimeUnit;
96-
9792
import org.json.JSONArray;
9893
import org.json.JSONException;
9994
import org.json.JSONObject;
@@ -103,9 +98,7 @@
10398
import org.mockito.ArgumentCaptor;
10499
import org.mockito.Mock;
105100
import org.mockito.MockitoAnnotations;
106-
import org.robolectric.Robolectric;
107101
import org.robolectric.RobolectricTestRunner;
108-
import org.robolectric.android.util.concurrent.InlineExecutorService;
109102
import org.robolectric.annotation.Config;
110103
import org.robolectric.annotation.LooperMode;
111104
import org.skyscreamer.jsonassert.JSONAssert;
@@ -193,7 +186,8 @@ public final class FirebaseRemoteConfigTest {
193186
private ConfigRealtimeHttpClient configRealtimeHttpClient;
194187
private FetchResponse firstFetchedContainerResponse;
195188

196-
private final ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
189+
private final ScheduledExecutorService scheduledExecutorService =
190+
Executors.newSingleThreadScheduledExecutor();
197191

198192
@Before
199193
public void setUp() throws Exception {
@@ -338,7 +332,7 @@ public void onError(@NonNull FirebaseRemoteConfigException error) {
338332
mockActivatedCache,
339333
listeners,
340334
mockRetryListener,
341-
executorService);
335+
scheduledExecutorService);
342336
configRealtimeHttpClient =
343337
new ConfigRealtimeHttpClient(
344338
firebaseApp,
@@ -348,7 +342,7 @@ public void onError(@NonNull FirebaseRemoteConfigException error) {
348342
context,
349343
"firebase",
350344
listeners,
351-
executorService);
345+
scheduledExecutorService);
352346
}
353347

354348
@Test
@@ -1321,21 +1315,22 @@ public void realtime_stream_autofetch_success() throws Exception {
13211315
when(mockFetchHandler.fetch(0L)).thenReturn(Tasks.forResult(realtimeFetchedContainerResponse));
13221316

13231317
configAutoFetch.fetchLatestConfig(1, 1);
1324-
flushTasks();
1318+
flushScheduledTasks();
13251319

13261320
Set<String> updatedParams = Sets.newHashSet("realtime_param");
13271321
verify(mockOnUpdateListener).onUpdate(updatedParams);
13281322
}
13291323

13301324
@Test
1331-
public void realtime_autofetchBeforeActivate_callsOnUpdateWithAllFetchedParams() throws Exception {
1325+
public void realtime_autofetchBeforeActivate_callsOnUpdateWithAllFetchedParams()
1326+
throws Exception {
13321327
// The first call to get() returns null while the cache is loading.
13331328
loadCacheWithConfig(mockActivatedCache, null);
13341329
when(mockFetchHandler.getTemplateVersionNumber()).thenReturn(1L);
13351330
when(mockFetchHandler.fetch(0)).thenReturn(Tasks.forResult(realtimeFetchedContainerResponse));
13361331

13371332
configAutoFetch.fetchLatestConfig(1, 1);
1338-
flushTasks();
1333+
flushScheduledTasks();
13391334

13401335
Set<String> updatedParams = Sets.newHashSet("string_param", "long_param", "realtime_param");
13411336
verify(mockOnUpdateListener).onUpdate(updatedParams);
@@ -1348,7 +1343,7 @@ public void realtime_stream_autofetch_failure() throws Exception {
13481343
when(mockFetchHandler.fetch(0)).thenReturn(Tasks.forResult(realtimeFetchedContainerResponse));
13491344

13501345
configAutoFetch.fetchLatestConfig(1, 1000);
1351-
flushTasks();
1346+
flushScheduledTasks();
13521347

13531348
verify(mockNotFetchedEventListener).onError(any(FirebaseRemoteConfigServerException.class));
13541349
}
@@ -1431,14 +1426,16 @@ private static FirebaseApp initializeFirebaseApp(Context context) {
14311426
}
14321427

14331428
/**
1434-
* Flush tasks on the {@code executorService}'s thread.
1429+
* Flush tasks on the {@code scheduledExecutorService}'s thread.
14351430
*
1436-
* @throws InterruptedException
1431+
* @throws InterruptedException if the thread is interrupted while waiting.
14371432
*/
1438-
private void flushTasks() throws InterruptedException {
1433+
private void flushScheduledTasks() throws InterruptedException {
1434+
// Create a latch with a count of 1 and submit an execution request to countdown.
1435+
// When the existing tasks have been executed, the countdown will execute and release the latch.
14391436
CountDownLatch latch = new CountDownLatch(1);
1440-
executorService.execute(latch::countDown);
1441-
assertTrue("Task didn't finish", latch.await(10, TimeUnit.MILLISECONDS));
1437+
scheduledExecutorService.execute(latch::countDown);
1438+
assertTrue("Task didn't finish.", latch.await(10, TimeUnit.MILLISECONDS));
14421439
}
14431440

14441441
private ConfigUpdateListener generateEmptyRealtimeListener() {

firebase-config/src/test/java/com/google/firebase/remoteconfig/RemoteConfigComponentTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import java.util.concurrent.ExecutorService;
4444
import java.util.concurrent.Executors;
4545
import java.util.concurrent.ScheduledExecutorService;
46-
4746
import org.junit.Before;
4847
import org.junit.Test;
4948
import org.junit.runner.RunWith;
@@ -177,7 +176,7 @@ private RemoteConfigComponent getNewFrcComponent() {
177176
return new RemoteConfigComponent(
178177
context,
179178
directExecutor,
180-
scheduledExecutorService,
179+
scheduledExecutorService,
181180
mockFirebaseApp,
182181
mockFirebaseInstallations,
183182
mockFirebaseAbt,

firebase-config/src/test/java/com/google/firebase/remoteconfig/internal/ConfigContainerTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,12 @@ public void getChangedParams_noChanges_returnsEmptySet() throws Exception {
149149

150150
@Test
151151
public void getChangedParams_emptyConfig_returnsAllOtherParams() throws Exception {
152-
ConfigContainer config =
153-
ConfigContainer.newBuilder()
154-
.build();
152+
ConfigContainer config = ConfigContainer.newBuilder().build();
155153

156154
ConfigContainer other =
157-
ConfigContainer.newBuilder()
158-
.replaceConfigsWith(ImmutableMap.of("string_param", "value_1"))
159-
.build();
155+
ConfigContainer.newBuilder()
156+
.replaceConfigsWith(ImmutableMap.of("string_param", "value_1"))
157+
.build();
160158

161159
Set<String> changedParams = config.getChangedParams(other);
162160

0 commit comments

Comments
 (0)