diff --git a/src/main/java/com/google/firebase/FirebaseApp.java b/src/main/java/com/google/firebase/FirebaseApp.java index c60f0ad5e..28efa9d47 100644 --- a/src/main/java/com/google/firebase/FirebaseApp.java +++ b/src/main/java/com/google/firebase/FirebaseApp.java @@ -34,7 +34,6 @@ import com.google.common.base.Joiner; import com.google.common.base.MoreObjects; import com.google.common.base.Strings; -import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.firebase.internal.FirebaseAppStore; import com.google.firebase.internal.FirebaseScheduledExecutor; @@ -121,7 +120,6 @@ private FirebaseApp(String name, FirebaseOptions options, TokenRefresher.Factory /** Returns a list of all FirebaseApps. */ public static List getApps() { - // TODO: reenable persistence. See b/28158809. synchronized (appsLock) { return ImmutableList.copyOf(instances.values()); } @@ -582,18 +580,17 @@ enum State { private static FirebaseOptions getOptionsFromEnvironment() throws IOException { String defaultConfig = System.getenv(FIREBASE_CONFIG_ENV_VAR); if (Strings.isNullOrEmpty(defaultConfig)) { - return new FirebaseOptions.Builder() + return FirebaseOptions.builder() .setCredentials(APPLICATION_DEFAULT_CREDENTIALS) .build(); } JsonFactory jsonFactory = Utils.getDefaultJsonFactory(); - FirebaseOptions.Builder builder = new FirebaseOptions.Builder(); + FirebaseOptions.Builder builder = FirebaseOptions.builder(); JsonParser parser; if (defaultConfig.startsWith("{")) { parser = jsonFactory.createJsonParser(defaultConfig); } else { - FileReader reader; - reader = new FileReader(defaultConfig); + FileReader reader = new FileReader(defaultConfig); parser = jsonFactory.createJsonParser(reader); } parser.parseAndClose(builder); diff --git a/src/main/java/com/google/firebase/FirebaseAppLifecycleListener.java b/src/main/java/com/google/firebase/FirebaseAppLifecycleListener.java index 60118c249..6493edb60 100644 --- a/src/main/java/com/google/firebase/FirebaseAppLifecycleListener.java +++ b/src/main/java/com/google/firebase/FirebaseAppLifecycleListener.java @@ -19,7 +19,7 @@ /** * A listener which gets notified when {@link com.google.firebase.FirebaseApp} gets deleted. */ -// TODO: consider making it public in a future release. +@Deprecated interface FirebaseAppLifecycleListener { /** diff --git a/src/main/java/com/google/firebase/FirebaseOptions.java b/src/main/java/com/google/firebase/FirebaseOptions.java index f0561d5e5..4ca068725 100644 --- a/src/main/java/com/google/firebase/FirebaseOptions.java +++ b/src/main/java/com/google/firebase/FirebaseOptions.java @@ -223,6 +223,16 @@ public static Builder builder() { return new Builder(); } + /** + * Creates a new Builder from the options object. + * + *

The new builder is not backed by this object's values, that is changes made to the new + * builder don't change the values of the origin object. + */ + public Builder toBuilder() { + return new Builder(this); + } + /** * Builder for constructing {@link FirebaseOptions}. */ @@ -249,7 +259,12 @@ public static final class Builder { private int connectTimeout; private int readTimeout; - /** Constructs an empty builder. */ + /** + * Constructs an empty builder. + * + * @deprecated Use {@link FirebaseOptions#builder()} instead. + */ + @Deprecated public Builder() {} /** @@ -257,7 +272,10 @@ public Builder() {} * *

The new builder is not backed by this object's values, that is changes made to the new * builder don't change the values of the origin object. + * + * @deprecated Use {@link FirebaseOptions#toBuilder()} instead. */ + @Deprecated public Builder(FirebaseOptions options) { databaseUrl = options.databaseUrl; storageBucket = options.storageBucket; diff --git a/src/main/java/com/google/firebase/auth/FirebaseAuth.java b/src/main/java/com/google/firebase/auth/FirebaseAuth.java index a7c36039f..7cd738ec5 100644 --- a/src/main/java/com/google/firebase/auth/FirebaseAuth.java +++ b/src/main/java/com/google/firebase/auth/FirebaseAuth.java @@ -758,14 +758,6 @@ public void setCustomUserClaims(@NonNull String uid, setCustomUserClaimsOp(uid, claims).call(); } - /** - * @deprecated Use {@link #setCustomUserClaims(String, Map)} instead. - */ - public void setCustomClaims(@NonNull String uid, - @Nullable Map claims) throws FirebaseAuthException { - setCustomUserClaims(uid, claims); - } - /** * Similar to {@link #setCustomUserClaims(String, Map)} but performs the operation asynchronously. * diff --git a/src/main/java/com/google/firebase/database/core/JvmAuthTokenProvider.java b/src/main/java/com/google/firebase/database/core/JvmAuthTokenProvider.java index a1cb79688..9b862ba86 100644 --- a/src/main/java/com/google/firebase/database/core/JvmAuthTokenProvider.java +++ b/src/main/java/com/google/firebase/database/core/JvmAuthTokenProvider.java @@ -112,7 +112,7 @@ private static class TokenChangeListenerWrapper implements CredentialsChangedLis } @Override - public void onChanged(OAuth2Credentials credentials) throws IOException { + public void onChanged(OAuth2Credentials credentials) { // When this event fires, it is guaranteed that credentials.getAccessToken() will return a // valid OAuth2 token. final AccessToken accessToken = credentials.getAccessToken(); diff --git a/src/main/java/com/google/firebase/messaging/Notification.java b/src/main/java/com/google/firebase/messaging/Notification.java index d9b2034ee..efed46deb 100644 --- a/src/main/java/com/google/firebase/messaging/Notification.java +++ b/src/main/java/com/google/firebase/messaging/Notification.java @@ -33,33 +33,6 @@ public class Notification { @Key("image") private final String image; - /** - * Creates a new {@code Notification} using the given title and body. - * - * @param title Title of the notification. - * @param body Body of the notification. - * - * @deprecated Use {@link #Notification(Builder)} instead. - */ - public Notification(String title, String body) { - this(title, body, null); - } - - /** - * Creates a new {@code Notification} using the given title, body, and image. - * - * @param title Title of the notification. - * @param body Body of the notification. - * @param imageUrl URL of the image that is going to be displayed in the notification. - * - * @deprecated Use {@link #Notification(Builder)} instead. - */ - public Notification(String title, String body, String imageUrl) { - this.title = title; - this.body = body; - this.image = imageUrl; - } - private Notification(Builder builder) { this.title = builder.title; this.body = builder.body; diff --git a/src/test/java/com/google/firebase/FirebaseAppTest.java b/src/test/java/com/google/firebase/FirebaseAppTest.java index 77191fa4c..d481e3c0e 100644 --- a/src/test/java/com/google/firebase/FirebaseAppTest.java +++ b/src/test/java/com/google/firebase/FirebaseAppTest.java @@ -35,13 +35,11 @@ import com.google.auth.oauth2.OAuth2Credentials.CredentialsChangedListener; import com.google.common.base.Defaults; import com.google.common.base.Strings; -import com.google.common.base.Supplier; import com.google.common.base.Suppliers; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.firebase.FirebaseApp.TokenRefresher; -import com.google.firebase.FirebaseOptions.Builder; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.testing.FirebaseAppRule; import com.google.firebase.testing.ServiceAccount; @@ -74,7 +72,7 @@ public class FirebaseAppTest { private static final FirebaseOptions OPTIONS = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .build(); @@ -110,7 +108,7 @@ public void testGetInstancePersistedNotInitialized() { @Test public void testGetProjectIdFromOptions() { - FirebaseOptions options = new FirebaseOptions.Builder(OPTIONS) + FirebaseOptions options = OPTIONS.toBuilder() .setProjectId("explicit-project-id") .build(); FirebaseApp app = FirebaseApp.initializeApp(options, "myApp"); @@ -131,7 +129,7 @@ public void testGetProjectIdFromEnvironment() { for (String variable : variables) { String gcloudProject = System.getenv(variable); TestUtils.setEnvironmentVariables(ImmutableMap.of(variable, "project-id-1")); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .build(); try { @@ -155,7 +153,7 @@ public void testProjectIdEnvironmentVariablePrecedence() { TestUtils.setEnvironmentVariables(ImmutableMap.of( "GCLOUD_PROJECT", "project-id-1", "GOOGLE_CLOUD_PROJECT", "project-id-2")); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .build(); try { @@ -239,7 +237,7 @@ public void testGetNullApp() { @Test public void testToString() throws IOException { FirebaseOptions options = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .build(); FirebaseApp app = FirebaseApp.initializeApp(options, "app"); @@ -461,14 +459,13 @@ public void testTokenRefresherStateMachine() { @Test public void testAppWithAuthVariableOverrides() { Map authVariableOverrides = ImmutableMap.of("uid", "uid1"); - FirebaseOptions options = - new FirebaseOptions.Builder(getMockCredentialOptions()) - .setDatabaseAuthVariableOverride(authVariableOverrides) - .build(); + FirebaseOptions options = getMockCredentialOptions().toBuilder() + .setDatabaseAuthVariableOverride(authVariableOverrides) + .build(); FirebaseApp app = FirebaseApp.initializeApp(options, "testGetAppWithUid"); assertEquals("uid1", app.getOptions().getDatabaseAuthVariableOverride().get("uid")); String token = TestOnlyImplFirebaseTrampolines.getToken(app, false); - Assert.assertTrue(!token.isEmpty()); + Assert.assertFalse(token.isEmpty()); } @Test(expected = IllegalArgumentException.class) @@ -599,7 +596,7 @@ private static void setFirebaseConfigEnvironmentVariable(String configJSON) { } private static FirebaseOptions getMockCredentialOptions() { - return new Builder().setCredentials(new MockGoogleCredentials()).build(); + return FirebaseOptions.builder().setCredentials(new MockGoogleCredentials()).build(); } private static void invokePublicInstanceMethodWithDefaultValues(Object instance, Method method) diff --git a/src/test/java/com/google/firebase/FirebaseOptionsTest.java b/src/test/java/com/google/firebase/FirebaseOptionsTest.java index af7f9846d..c74215beb 100644 --- a/src/test/java/com/google/firebase/FirebaseOptionsTest.java +++ b/src/test/java/com/google/firebase/FirebaseOptionsTest.java @@ -48,7 +48,7 @@ public class FirebaseOptionsTest { private static final String FIREBASE_PROJECT_ID = "explicit-project-id"; private static final FirebaseOptions ALL_VALUES_OPTIONS = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setDatabaseUrl(FIREBASE_DB_URL) .setStorageBucket(FIREBASE_STORAGE_BUCKET) .setProjectId(FIREBASE_PROJECT_ID) @@ -77,7 +77,7 @@ public void createOptionsWithAllValuesSet() throws IOException { NetHttpTransport httpTransport = new NetHttpTransport(); FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder().build(); FirebaseOptions firebaseOptions = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setDatabaseUrl(FIREBASE_DB_URL) .setStorageBucket(FIREBASE_STORAGE_BUCKET) .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) @@ -110,7 +110,7 @@ public void createOptionsWithAllValuesSet() throws IOException { @Test public void createOptionsWithOnlyMandatoryValuesSet() throws IOException { FirebaseOptions firebaseOptions = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .build(); assertNotNull(firebaseOptions.getJsonFactory()); @@ -133,7 +133,7 @@ public void createOptionsWithOnlyMandatoryValuesSet() throws IOException { @Test public void createOptionsWithCustomFirebaseCredential() { FirebaseOptions firebaseOptions = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(new GoogleCredentials() { @Override public AccessToken refreshAccessToken() { @@ -153,17 +153,17 @@ public AccessToken refreshAccessToken() { @Test(expected = NullPointerException.class) public void createOptionsWithCredentialMissing() { - new FirebaseOptions.Builder().build().getCredentials(); + FirebaseOptions.builder().build().getCredentials(); } @Test(expected = NullPointerException.class) public void createOptionsWithNullCredentials() { - new FirebaseOptions.Builder().setCredentials((GoogleCredentials) null).build(); + FirebaseOptions.builder().setCredentials((GoogleCredentials) null).build(); } @Test(expected = IllegalArgumentException.class) public void createOptionsWithStorageBucketUrl() throws IOException { - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setStorageBucket("gs://mock-storage-bucket") .build(); @@ -171,7 +171,7 @@ public void createOptionsWithStorageBucketUrl() throws IOException { @Test(expected = NullPointerException.class) public void createOptionsWithNullThreadManager() { - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .setThreadManager(null) .build(); @@ -179,7 +179,7 @@ public void createOptionsWithNullThreadManager() { @Test public void checkToBuilderCreatesNewEquivalentInstance() { - FirebaseOptions allValuesOptionsCopy = new FirebaseOptions.Builder(ALL_VALUES_OPTIONS).build(); + FirebaseOptions allValuesOptionsCopy = ALL_VALUES_OPTIONS.toBuilder().build(); assertNotSame(ALL_VALUES_OPTIONS, allValuesOptionsCopy); assertEquals(ALL_VALUES_OPTIONS.getCredentials(), allValuesOptionsCopy.getCredentials()); assertEquals(ALL_VALUES_OPTIONS.getDatabaseUrl(), allValuesOptionsCopy.getDatabaseUrl()); @@ -195,7 +195,7 @@ public void checkToBuilderCreatesNewEquivalentInstance() { @Test(expected = IllegalArgumentException.class) public void createOptionsWithInvalidConnectTimeout() { - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .setConnectTimeout(-1) .build(); @@ -203,7 +203,7 @@ public void createOptionsWithInvalidConnectTimeout() { @Test(expected = IllegalArgumentException.class) public void createOptionsWithInvalidReadTimeout() { - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .setReadTimeout(-1) .build(); @@ -213,11 +213,11 @@ public void createOptionsWithInvalidReadTimeout() { public void testNotEquals() throws IOException { GoogleCredentials credentials = GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream()); FirebaseOptions options1 = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseOptions options2 = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(credentials) .setDatabaseUrl("https://test.firebaseio.com") .build(); diff --git a/src/test/java/com/google/firebase/ThreadManagerTest.java b/src/test/java/com/google/firebase/ThreadManagerTest.java index d8689a4da..22401de30 100644 --- a/src/test/java/com/google/firebase/ThreadManagerTest.java +++ b/src/test/java/com/google/firebase/ThreadManagerTest.java @@ -187,8 +187,7 @@ public void testAppLifecycleWithServiceCall() { } @Test - public void testAppLifecycleWithMultipleServiceCalls() - throws ExecutionException, InterruptedException { + public void testAppLifecycleWithMultipleServiceCalls() { MockThreadManager threadManager = new MockThreadManager(executor); // Initializing an app should initialize the executor. @@ -235,7 +234,7 @@ public void testAppLifecycleWithMultipleServiceCalls() } private FirebaseOptions buildOptions(ThreadManager threadManager) { - return new FirebaseOptions.Builder() + return FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .setProjectId("mock-project-id") .setThreadManager(threadManager) @@ -278,7 +277,7 @@ private static class Event { private final FirebaseApp app; private ExecutorService executor; - public Event(int type, @Nullable FirebaseApp app, @Nullable ExecutorService executor) { + Event(int type, @Nullable FirebaseApp app, @Nullable ExecutorService executor) { this.type = type; this.app = app; this.executor = executor; diff --git a/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java b/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java index 971493ff7..c36013c7f 100644 --- a/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java +++ b/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java @@ -405,7 +405,7 @@ public void testCustomTokenWithIAM() throws Exception { if (token == null) { token = credentials.refreshAccessToken(); } - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.create(token)) .setServiceAccountId(((ServiceAccountSigner) credentials).getAccount()) .setProjectId(IntegrationTestUtils.getProjectId()) diff --git a/src/test/java/com/google/firebase/auth/FirebaseAuthTest.java b/src/test/java/com/google/firebase/auth/FirebaseAuthTest.java index 93f187e31..46309b99d 100644 --- a/src/test/java/com/google/firebase/auth/FirebaseAuthTest.java +++ b/src/test/java/com/google/firebase/auth/FirebaseAuthTest.java @@ -60,7 +60,7 @@ public class FirebaseAuthTest { private static final FirebaseAuthException testException = new FirebaseAuthException( ErrorCode.INVALID_ARGUMENT, "Test error message", null, null, null); private static final long VALID_SINCE = 1494364393; - public static final String TEST_USER = "testUser"; + private static final String TEST_USER = "testUser"; @After public void cleanup() { @@ -539,7 +539,7 @@ private FirebaseApp getFirebaseAppForUserRetrieval() { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(new MockLowLevelHttpResponse().setContent(getUserResponse)) .build(); - return FirebaseApp.initializeApp(new FirebaseOptions.Builder() + return FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setHttpTransport(transport) .setProjectId("test-project-id") diff --git a/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java b/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java index 07e51cc80..af4577053 100644 --- a/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java +++ b/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java @@ -83,7 +83,7 @@ public void tearDown() { @Test public void testProjectIdRequired() { - FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(credentials) .build()); FirebaseAuth auth = FirebaseAuth.getInstance(); @@ -682,7 +682,7 @@ public void testGetUserUnexpectedHttpError() throws Exception { public void testTimeout() throws Exception { MockHttpTransport transport = new MultiRequestMockHttpTransport(ImmutableList.of( new MockLowLevelHttpResponse().setContent(TestUtils.loadResource("getUser.json")))); - FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(credentials) .setProjectId("test-project-id") .setHttpTransport(transport) @@ -1279,7 +1279,7 @@ private static TestResponseInterceptor initializeAppForUserManagement(String ... mocks.add(new MockLowLevelHttpResponse().setContent(response)); } MockHttpTransport transport = new MultiRequestMockHttpTransport(mocks); - FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(credentials) .setHttpTransport(transport) .setProjectId("test-project-id") @@ -1295,7 +1295,7 @@ private static FirebaseAuth getRetryDisabledAuth(MockLowLevelHttpResponse respon final MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); - final FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + final FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(credentials) .setProjectId("test-project-id") .setHttpTransport(transport) diff --git a/src/test/java/com/google/firebase/auth/internal/CryptoSignersTest.java b/src/test/java/com/google/firebase/auth/internal/CryptoSignersTest.java index af25e256d..32f9fd543 100644 --- a/src/test/java/com/google/firebase/auth/internal/CryptoSignersTest.java +++ b/src/test/java/com/google/firebase/auth/internal/CryptoSignersTest.java @@ -155,7 +155,7 @@ public void testMetadataService() throws Exception { ImmutableList.of( new MockLowLevelHttpResponse().setContent("metadata-server@iam.gserviceaccount.com"), new MockLowLevelHttpResponse().setContent(response))); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setHttpTransport(transport) .build(); @@ -185,7 +185,7 @@ public void testExplicitServiceAccountEmail() throws Exception { MockHttpTransport transport = new MultiRequestMockHttpTransport( ImmutableList.of( new MockLowLevelHttpResponse().setContent(response))); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setServiceAccountId("explicit-service-account@iam.gserviceaccount.com") .setCredentials(new MockGoogleCredentialsWithSigner("test-token")) .setHttpTransport(transport) @@ -208,7 +208,7 @@ public void testExplicitServiceAccountEmail() throws Exception { @Test public void testCredentialsWithSigner() throws Exception { // Should fall back to signing-enabled credential - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentialsWithSigner("test-token")) .build(); FirebaseApp app = FirebaseApp.initializeApp(options, "customApp"); diff --git a/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java b/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java index 03627f202..08ee49ff0 100644 --- a/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java +++ b/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java @@ -12,7 +12,6 @@ import com.google.cloud.firestore.FirestoreOptions; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseOptions; -import com.google.firebase.FirebaseOptions.Builder; import com.google.firebase.ImplFirebaseTrampolines; import com.google.firebase.TestOnlyImplFirebaseTrampolines; import com.google.firebase.auth.MockGoogleCredentials; @@ -23,11 +22,10 @@ public class FirestoreClientTest { - public static final FirestoreOptions FIRESTORE_OPTIONS = FirestoreOptions.newBuilder() + private static final FirestoreOptions FIRESTORE_OPTIONS = FirestoreOptions.newBuilder() // Setting credentials is not required (they get overridden by Admin SDK), but without // this Firestore logs an ugly warning during tests. .setCredentials(new MockGoogleCredentials("test-token")) - .setTimestampsInSnapshotsEnabled(true) .build(); @After @@ -37,7 +35,7 @@ public void tearDown() { @Test public void testExplicitProjectId() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setProjectId("explicit-project-id") .setFirestoreOptions(FIRESTORE_OPTIONS) @@ -51,7 +49,7 @@ public void testExplicitProjectId() throws IOException { @Test public void testServiceAccountProjectId() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setFirestoreOptions(FIRESTORE_OPTIONS) .build()); @@ -64,7 +62,7 @@ public void testServiceAccountProjectId() throws IOException { @Test public void testFirestoreOptions() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setProjectId("explicit-project-id") .setFirestoreOptions(FIRESTORE_OPTIONS) @@ -80,11 +78,10 @@ public void testFirestoreOptions() throws IOException { @Test public void testFirestoreOptionsOverride() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setProjectId("explicit-project-id") .setFirestoreOptions(FirestoreOptions.newBuilder() - .setTimestampsInSnapshotsEnabled(true) .setProjectId("other-project-id") .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .build()) @@ -104,7 +101,7 @@ public void testFirestoreOptionsOverride() throws IOException { @Test public void testAppDelete() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setProjectId("mock-project-id") .setFirestoreOptions(FIRESTORE_OPTIONS) diff --git a/src/test/java/com/google/firebase/cloud/StorageClientTest.java b/src/test/java/com/google/firebase/cloud/StorageClientTest.java index 41535f3d9..190fad6cc 100644 --- a/src/test/java/com/google/firebase/cloud/StorageClientTest.java +++ b/src/test/java/com/google/firebase/cloud/StorageClientTest.java @@ -41,7 +41,7 @@ public void tearDown() { @Test public void testInvalidConfiguration() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .build()); try { @@ -54,7 +54,7 @@ public void testInvalidConfiguration() throws IOException { @Test public void testInvalidBucketName() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setStorageBucket("mock-bucket-name") .build()); @@ -75,7 +75,7 @@ public void testInvalidBucketName() throws IOException { @Test public void testAppDelete() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setStorageBucket("mock-bucket-name") .build()); @@ -93,7 +93,7 @@ public void testAppDelete() throws IOException { @Test public void testNonExistingBucket() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setStorageBucket("mock-bucket-name") .build()); @@ -115,7 +115,7 @@ public void testNonExistingBucket() throws IOException { @Test public void testBucket() throws IOException { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setStorageBucket("mock-bucket-name") .build()); diff --git a/src/test/java/com/google/firebase/database/DataSnapshotTest.java b/src/test/java/com/google/firebase/database/DataSnapshotTest.java index 0764bdbf4..083d8ce09 100644 --- a/src/test/java/com/google/firebase/database/DataSnapshotTest.java +++ b/src/test/java/com/google/firebase/database/DataSnapshotTest.java @@ -51,7 +51,7 @@ public class DataSnapshotTest { @BeforeClass public static void setUpClass() throws IOException { testApp = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl("https://admin-java-sdk.firebaseio.com") .build()); diff --git a/src/test/java/com/google/firebase/database/DatabaseReferenceTest.java b/src/test/java/com/google/firebase/database/DatabaseReferenceTest.java index 5e7fc5374..207173f74 100644 --- a/src/test/java/com/google/firebase/database/DatabaseReferenceTest.java +++ b/src/test/java/com/google/firebase/database/DatabaseReferenceTest.java @@ -64,7 +64,7 @@ public class DatabaseReferenceTest { @BeforeClass public static void setUpClass() throws IOException { testApp = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl(DB_URL) .build()); diff --git a/src/test/java/com/google/firebase/database/FirebaseDatabaseTest.java b/src/test/java/com/google/firebase/database/FirebaseDatabaseTest.java index d8395035e..c9c8decd7 100644 --- a/src/test/java/com/google/firebase/database/FirebaseDatabaseTest.java +++ b/src/test/java/com/google/firebase/database/FirebaseDatabaseTest.java @@ -39,12 +39,12 @@ public class FirebaseDatabaseTest { private static final FirebaseOptions firebaseOptions = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl("https://firebase-db-test.firebaseio.com") .build(); private static final FirebaseOptions firebaseOptionsWithoutDatabaseUrl = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .build(); diff --git a/src/test/java/com/google/firebase/database/core/JvmAuthTokenProviderTest.java b/src/test/java/com/google/firebase/database/core/JvmAuthTokenProviderTest.java index 7b8fe5229..fd9089ce4 100644 --- a/src/test/java/com/google/firebase/database/core/JvmAuthTokenProviderTest.java +++ b/src/test/java/com/google/firebase/database/core/JvmAuthTokenProviderTest.java @@ -67,7 +67,7 @@ public void testGetToken() throws IOException, InterruptedException { credentials.refresh(); assertEquals(1, refreshDetector.count); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseApp app = FirebaseApp.initializeApp(options); @@ -87,7 +87,7 @@ public void testGetTokenNoRefresh() throws IOException, InterruptedException { credentials.refresh(); assertEquals(1, refreshDetector.count); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseApp app = FirebaseApp.initializeApp(options); @@ -103,7 +103,7 @@ public void testGetTokenNoRefresh() throws IOException, InterruptedException { public void testGetTokenWithAuthOverrides() throws InterruptedException, IOException { MockGoogleCredentials credentials = new MockGoogleCredentials("mock-token"); Map auth = ImmutableMap.of("uid", "test"); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .setDatabaseAuthVariableOverride(auth) .build(); @@ -119,11 +119,11 @@ public void testGetTokenWithAuthOverrides() throws InterruptedException, IOExcep public void testGetTokenError() throws InterruptedException { MockGoogleCredentials credentials = new MockGoogleCredentials("mock-token") { @Override - public AccessToken refreshAccessToken() throws IOException { + public AccessToken refreshAccessToken() { throw new RuntimeException("Test error"); } }; - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseApp app = FirebaseApp.initializeApp(options); @@ -139,13 +139,13 @@ public void testAddTokenChangeListener() throws IOException { final AtomicInteger counter = new AtomicInteger(0); MockGoogleCredentials credentials = new MockGoogleCredentials() { @Override - public AccessToken refreshAccessToken() throws IOException { + public AccessToken refreshAccessToken() { Date expiry = new Date(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1)); return new AccessToken("token-" + counter.getAndIncrement(), expiry); } }; - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseApp app = FirebaseApp.initializeApp(options); @@ -172,7 +172,7 @@ public void onTokenChange(String token) { @Test public void testTokenChangeListenerThread() throws InterruptedException, IOException { MockGoogleCredentials credentials = new MockGoogleCredentials(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseApp app = FirebaseApp.initializeApp(options); @@ -210,12 +210,12 @@ public void testTokenAutoRefresh() throws InterruptedException { final Semaphore semaphore = new Semaphore(0); credentials.addChangeListener(new OAuth2Credentials.CredentialsChangedListener() { @Override - public void onChanged(OAuth2Credentials credentials) throws IOException { + public void onChanged(OAuth2Credentials credentials) { semaphore.release(); } }); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(credentials) .build(); FirebaseApp app = FirebaseApp.initializeApp(options); @@ -234,7 +234,7 @@ private void assertToken(String token, String expectedToken, Map assertEquals(expectedToken, map.get("token")); - Map auth = (Map)map.get("auth"); + Map auth = (Map) map.get("auth"); DeepEquals.deepEquals(expectedAuth, auth); } @@ -271,7 +271,7 @@ private static class TokenRefreshDetector private int count = 0; @Override - public void onChanged(OAuth2Credentials credentials) throws IOException { + public void onChanged(OAuth2Credentials credentials) { count++; } } diff --git a/src/test/java/com/google/firebase/database/core/JvmPlatformTest.java b/src/test/java/com/google/firebase/database/core/JvmPlatformTest.java index c6912916f..044b583b3 100644 --- a/src/test/java/com/google/firebase/database/core/JvmPlatformTest.java +++ b/src/test/java/com/google/firebase/database/core/JvmPlatformTest.java @@ -56,7 +56,7 @@ protected ThreadFactory getThreadFactory() { return Executors.defaultThreadFactory(); } }; - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .setThreadManager(threadManager) .build(); @@ -80,7 +80,7 @@ protected ThreadFactory getThreadFactory() { @Test public void userAgentHasCorrectParts() { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .build(); FirebaseApp app = FirebaseApp.initializeApp(options, "userAgentApp"); diff --git a/src/test/java/com/google/firebase/database/core/RepoTest.java b/src/test/java/com/google/firebase/database/core/RepoTest.java index ec9696e55..9c2281d4c 100644 --- a/src/test/java/com/google/firebase/database/core/RepoTest.java +++ b/src/test/java/com/google/firebase/database/core/RepoTest.java @@ -61,7 +61,7 @@ public class RepoTest { @BeforeClass public static void setUpClass() throws IOException { FirebaseApp testApp = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl("https://admin-java-sdk.firebaseio.com") .build()); diff --git a/src/test/java/com/google/firebase/database/core/SyncPointTest.java b/src/test/java/com/google/firebase/database/core/SyncPointTest.java index 91be0cce7..158a803e4 100644 --- a/src/test/java/com/google/firebase/database/core/SyncPointTest.java +++ b/src/test/java/com/google/firebase/database/core/SyncPointTest.java @@ -68,7 +68,7 @@ public class SyncPointTest { @BeforeClass public static void setUpClass() throws IOException { testApp = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl("https://admin-java-sdk.firebaseio.com") .build()); diff --git a/src/test/java/com/google/firebase/database/core/persistence/DefaultPersistenceManagerTest.java b/src/test/java/com/google/firebase/database/core/persistence/DefaultPersistenceManagerTest.java index 99450944c..342700a3d 100644 --- a/src/test/java/com/google/firebase/database/core/persistence/DefaultPersistenceManagerTest.java +++ b/src/test/java/com/google/firebase/database/core/persistence/DefaultPersistenceManagerTest.java @@ -56,7 +56,7 @@ public class DefaultPersistenceManagerTest { @BeforeClass public static void setUpClass() throws IOException { testApp = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl("https://admin-java-sdk.firebaseio.com") .build()); diff --git a/src/test/java/com/google/firebase/database/core/persistence/RandomPersistenceTest.java b/src/test/java/com/google/firebase/database/core/persistence/RandomPersistenceTest.java index 58358a8ff..d55db51c3 100644 --- a/src/test/java/com/google/firebase/database/core/persistence/RandomPersistenceTest.java +++ b/src/test/java/com/google/firebase/database/core/persistence/RandomPersistenceTest.java @@ -73,7 +73,7 @@ public class RandomPersistenceTest { @BeforeClass public static void setUpClass() throws IOException { testApp = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .setDatabaseUrl("https://admin-java-sdk.firebaseio.com") .build()); diff --git a/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseAuthTestIT.java b/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseAuthTestIT.java index d210039cc..58e313450 100644 --- a/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseAuthTestIT.java +++ b/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseAuthTestIT.java @@ -78,7 +78,7 @@ public void testAuthWithValidCertificateCredential() throws InterruptedException @Test public void testAuthWithInvalidCertificateCredential() throws InterruptedException, IOException { FirebaseOptions options = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setDatabaseUrl(IntegrationTestUtils.getDatabaseUrl()) .setCredentials(GoogleCredentials.fromStream(ServiceAccount.NONE.asStream())) .build(); @@ -94,10 +94,9 @@ public void testDatabaseAuthVariablesAuthorization() throws InterruptedException "uid", "test", "custom", "secret" ); - FirebaseOptions options = - new FirebaseOptions.Builder(masterApp.getOptions()) - .setDatabaseAuthVariableOverride(authVariableOverrides) - .build(); + FirebaseOptions options = masterApp.getOptions().toBuilder() + .setDatabaseAuthVariableOverride(authVariableOverrides) + .build(); FirebaseApp testUidApp = FirebaseApp.initializeApp(options, "testGetAppWithUid"); FirebaseDatabase masterDb = FirebaseDatabase.getInstance(masterApp); FirebaseDatabase testAuthOverridesDb = FirebaseDatabase.getInstance(testUidApp); @@ -114,10 +113,9 @@ public void testDatabaseAuthVariablesAuthorization() throws InterruptedException @Test public void testDatabaseAuthVariablesNoAuthorization() throws InterruptedException { - FirebaseOptions options = - new FirebaseOptions.Builder(masterApp.getOptions()) - .setDatabaseAuthVariableOverride(null) - .build(); + FirebaseOptions options = masterApp.getOptions().toBuilder() + .setDatabaseAuthVariableOverride(null) + .build(); FirebaseApp testUidApp = FirebaseApp.initializeApp(options, "testServiceAccountDatabaseWithNoAuth"); diff --git a/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseTestIT.java b/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseTestIT.java index f6451d9c5..84ec321a5 100644 --- a/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseTestIT.java +++ b/src/test/java/com/google/firebase/database/integration/FirebaseDatabaseTestIT.java @@ -255,7 +255,7 @@ public void onCancelled(DatabaseError error) { private static FirebaseApp appWithDbUrl(String dbUrl, String name) { try { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setDatabaseUrl(dbUrl) .setCredentials(GoogleCredentials.fromStream( IntegrationTestUtils.getServiceAccountCertificate())) @@ -268,7 +268,7 @@ private static FirebaseApp appWithDbUrl(String dbUrl, String name) { private static FirebaseApp appWithoutDbUrl(String name) { try { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream( IntegrationTestUtils.getServiceAccountCertificate())) .build(); diff --git a/src/test/java/com/google/firebase/database/integration/RulesTestIT.java b/src/test/java/com/google/firebase/database/integration/RulesTestIT.java index 1745ce220..b46c1287f 100644 --- a/src/test/java/com/google/firebase/database/integration/RulesTestIT.java +++ b/src/test/java/com/google/firebase/database/integration/RulesTestIT.java @@ -103,7 +103,7 @@ public class RulesTestIT { public static void setUpClass() throws IOException { // Init app with non-admin privileges Map auth = MapBuilder.of("uid", "my-service-worker"); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream( IntegrationTestUtils.getServiceAccountCertificate())) .setDatabaseUrl(IntegrationTestUtils.getDatabaseUrl()) diff --git a/src/test/java/com/google/firebase/database/integration/ShutdownExample.java b/src/test/java/com/google/firebase/database/integration/ShutdownExample.java index 020e0416e..ded28fe0f 100644 --- a/src/test/java/com/google/firebase/database/integration/ShutdownExample.java +++ b/src/test/java/com/google/firebase/database/integration/ShutdownExample.java @@ -32,7 +32,7 @@ public static void main(String[] args) { FirebaseApp app = FirebaseApp.initializeApp( - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setDatabaseUrl("https://admin-java-sdk.firebaseio.com") .build()); diff --git a/src/test/java/com/google/firebase/iid/FirebaseInstanceIdTest.java b/src/test/java/com/google/firebase/iid/FirebaseInstanceIdTest.java index 45b70cd34..f15861a62 100644 --- a/src/test/java/com/google/firebase/iid/FirebaseInstanceIdTest.java +++ b/src/test/java/com/google/firebase/iid/FirebaseInstanceIdTest.java @@ -76,7 +76,7 @@ public void tearDown() { @Test public void testNoProjectId() { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .build(); FirebaseApp.initializeApp(options); @@ -90,7 +90,7 @@ public void testNoProjectId() { @Test public void testInvalidInstanceId() { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId("test-project") .build(); @@ -122,7 +122,7 @@ public void testDeleteInstanceId() throws Exception { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId("test-project") .setHttpTransport(transport) @@ -168,7 +168,7 @@ public void testDeleteInstanceIdError() throws Exception { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId("test-project") .setHttpTransport(transport) @@ -205,7 +205,7 @@ public void testDeleteInstanceIdError() throws Exception { @Test public void testDeleteInstanceIdTransportError() throws Exception { HttpTransport transport = TestUtils.createFaultyHttpTransport(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId("test-project") .setHttpTransport(transport) @@ -235,7 +235,7 @@ public void testDeleteInstanceIdInvalidJsonIgnored() throws Exception { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId("test-project") .setHttpTransport(transport) diff --git a/src/test/java/com/google/firebase/internal/CallableOperationTest.java b/src/test/java/com/google/firebase/internal/CallableOperationTest.java index 2ead9a9c7..d38c96776 100644 --- a/src/test/java/com/google/firebase/internal/CallableOperationTest.java +++ b/src/test/java/com/google/firebase/internal/CallableOperationTest.java @@ -24,7 +24,6 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.firebase.FirebaseApp; import com.google.firebase.FirebaseOptions; -import com.google.firebase.FirebaseOptions.Builder; import com.google.firebase.TestOnlyImplFirebaseTrampolines; import com.google.firebase.auth.MockGoogleCredentials; import com.google.firebase.internal.FirebaseThreadManagers.GlobalThreadManager; @@ -38,7 +37,7 @@ public class CallableOperationTest { private static final String TEST_FIREBASE_THREAD = "test-firebase-thread"; - private static final FirebaseOptions OPTIONS = new Builder() + private static final FirebaseOptions OPTIONS = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .setThreadManager(new MockThreadManager()) .build(); diff --git a/src/test/java/com/google/firebase/internal/ErrorHandlingHttpClientTest.java b/src/test/java/com/google/firebase/internal/ErrorHandlingHttpClientTest.java index 9a224dbbb..31cc1d094 100644 --- a/src/test/java/com/google/firebase/internal/ErrorHandlingHttpClientTest.java +++ b/src/test/java/com/google/firebase/internal/ErrorHandlingHttpClientTest.java @@ -204,7 +204,7 @@ public void testRetryOnError() { .setLowLevelHttpRequest(request) .build(); - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("token")) .setHttpTransport(transport) .build()); @@ -240,7 +240,7 @@ public void testRequestInitializationError() { .setLowLevelHttpRequest(request) .build(); - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials() { @Override public AccessToken refreshAccessToken() throws IOException { diff --git a/src/test/java/com/google/firebase/internal/FirebaseAppStoreTest.java b/src/test/java/com/google/firebase/internal/FirebaseAppStoreTest.java index 4b3699d82..c9170daa3 100644 --- a/src/test/java/com/google/firebase/internal/FirebaseAppStoreTest.java +++ b/src/test/java/com/google/firebase/internal/FirebaseAppStoreTest.java @@ -16,7 +16,7 @@ package com.google.firebase.internal; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import com.google.auth.oauth2.GoogleCredentials; import com.google.firebase.FirebaseApp; @@ -34,7 +34,7 @@ public class FirebaseAppStoreTest { private static final String FIREBASE_DB_URL = "https://mock-project.firebaseio.com"; private static final FirebaseOptions ALL_VALUES_OPTIONS = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setDatabaseUrl(FIREBASE_DB_URL) .setCredentials(TestUtils.getCertCredential(ServiceAccount.EDITOR.asStream())) .build(); @@ -55,7 +55,7 @@ public void incompatibleAppInitializedDoesntThrow() throws IOException { FirebaseApp.initializeApp(ALL_VALUES_OPTIONS, name); TestOnlyImplFirebaseTrampolines.clearInstancesForTest(); FirebaseOptions options = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .build(); FirebaseApp.initializeApp(options, name); @@ -66,7 +66,7 @@ public void incompatibleDefaultAppInitializedDoesntThrow() throws IOException { FirebaseApp.initializeApp(ALL_VALUES_OPTIONS); TestOnlyImplFirebaseTrampolines.clearInstancesForTest(); FirebaseOptions options = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream())) .build(); FirebaseApp.initializeApp(options); @@ -78,6 +78,6 @@ public void persistenceDisabled() { FirebaseApp.initializeApp(ALL_VALUES_OPTIONS, name); TestOnlyImplFirebaseTrampolines.clearInstancesForTest(); FirebaseAppStore appStore = FirebaseAppStore.getInstance(); - assertTrue(!appStore.getAllPersistedAppNames().contains(name)); + assertFalse(appStore.getAllPersistedAppNames().contains(name)); } } diff --git a/src/test/java/com/google/firebase/internal/FirebaseRequestInitializerTest.java b/src/test/java/com/google/firebase/internal/FirebaseRequestInitializerTest.java index 1f610f5e3..fde2f918b 100644 --- a/src/test/java/com/google/firebase/internal/FirebaseRequestInitializerTest.java +++ b/src/test/java/com/google/firebase/internal/FirebaseRequestInitializerTest.java @@ -46,7 +46,7 @@ public void tearDown() { @Test public void testDefaultSettings() throws Exception { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("token")) .build()); HttpRequest request = TestUtils.createRequest(); @@ -65,7 +65,7 @@ public void testDefaultSettings() throws Exception { @Test public void testExplicitTimeouts() throws Exception { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("token")) .setConnectTimeout(CONNECT_TIMEOUT_MILLIS) .setReadTimeout(READ_TIMEOUT_MILLIS) @@ -85,7 +85,7 @@ public void testExplicitTimeouts() throws Exception { @Test public void testRetryConfig() throws Exception { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("token")) .build()); RetryConfig retryConfig = RetryConfig.builder() @@ -106,7 +106,7 @@ public void testRetryConfig() throws Exception { @Test public void testRetryConfigWithIOExceptionHandling() throws Exception { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("token")) .build()); RetryConfig retryConfig = RetryConfig.builder() @@ -128,7 +128,7 @@ public void testRetryConfigWithIOExceptionHandling() throws Exception { @Test public void testCredentialsRetryHandler() throws Exception { - FirebaseApp app = FirebaseApp.initializeApp(new FirebaseOptions.Builder() + FirebaseApp app = FirebaseApp.initializeApp(FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("token")) .build()); RetryConfig retryConfig = RetryConfig.builder() diff --git a/src/test/java/com/google/firebase/internal/FirebaseThreadManagersTest.java b/src/test/java/com/google/firebase/internal/FirebaseThreadManagersTest.java index 2b117f29f..286cdf09f 100644 --- a/src/test/java/com/google/firebase/internal/FirebaseThreadManagersTest.java +++ b/src/test/java/com/google/firebase/internal/FirebaseThreadManagersTest.java @@ -49,7 +49,7 @@ public void tearDown() { @Test public void testGlobalThreadManager() { MockThreadManager threadManager = new MockThreadManager(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .setThreadManager(threadManager) .build(); @@ -74,7 +74,7 @@ public void testGlobalThreadManager() { @Test public void testGlobalThreadManagerWithMultipleApps() { MockThreadManager threadManager = new MockThreadManager(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .build(); FirebaseApp defaultApp = FirebaseApp.initializeApp(options); @@ -99,7 +99,7 @@ public void testGlobalThreadManagerWithMultipleApps() { @Test public void testGlobalThreadManagerReInit() { MockThreadManager threadManager = new MockThreadManager(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .setThreadManager(threadManager) .build(); @@ -125,7 +125,7 @@ public void testGlobalThreadManagerReInit() { @Test public void testDefaultThreadManager() throws Exception { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials()) .build(); FirebaseApp defaultApp = FirebaseApp.initializeApp(options); diff --git a/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java b/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java index a93822595..9f8780e89 100644 --- a/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java +++ b/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java @@ -523,7 +523,7 @@ public void testBuilderNullChildRequestFactory() { @Test public void testFromApp() throws IOException { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId("test-project") .build(); diff --git a/src/test/java/com/google/firebase/messaging/FirebaseMessagingIT.java b/src/test/java/com/google/firebase/messaging/FirebaseMessagingIT.java index 4980d7c41..9ae7bba24 100644 --- a/src/test/java/com/google/firebase/messaging/FirebaseMessagingIT.java +++ b/src/test/java/com/google/firebase/messaging/FirebaseMessagingIT.java @@ -101,17 +101,26 @@ public void testSendAll() throws Exception { List messages = new ArrayList<>(); messages.add( Message.builder() - .setNotification(new Notification("Title", "Body")) + .setNotification(Notification.builder() + .setTitle("Title") + .setBody("Body") + .build()) .setTopic("foo-bar") .build()); messages.add( Message.builder() - .setNotification(new Notification("Title", "Body")) + .setNotification(Notification.builder() + .setTitle("Title") + .setBody("Body") + .build()) .setTopic("foo-bar") .build()); messages.add( Message.builder() - .setNotification(new Notification("Title", "Body")) + .setNotification(Notification.builder() + .setTitle("Title") + .setBody("Body") + .build()) .setToken("not-a-token") .build()); @@ -163,7 +172,10 @@ public void testSendFiveHundred() throws Exception { @Test public void testSendMulticast() throws Exception { MulticastMessage multicastMessage = MulticastMessage.builder() - .setNotification(new Notification("Title", "Body")) + .setNotification(Notification.builder() + .setTitle("Title") + .setBody("Body") + .build()) .addToken("not-a-token") .addToken("also-not-a-token") .build(); diff --git a/src/test/java/com/google/firebase/messaging/InstanceIdClientImplTest.java b/src/test/java/com/google/firebase/messaging/InstanceIdClientImplTest.java index bfbc88158..bac2a513d 100644 --- a/src/test/java/com/google/firebase/messaging/InstanceIdClientImplTest.java +++ b/src/test/java/com/google/firebase/messaging/InstanceIdClientImplTest.java @@ -368,7 +368,7 @@ public void testFromApp() { MockHttpTransport transport = new MockHttpTransport.Builder() .setLowLevelHttpResponse(response) .build(); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setHttpTransport(transport) .setProjectId("test-project") diff --git a/src/test/java/com/google/firebase/messaging/MessageTest.java b/src/test/java/com/google/firebase/messaging/MessageTest.java index 778b4f109..65caae293 100644 --- a/src/test/java/com/google/firebase/messaging/MessageTest.java +++ b/src/test/java/com/google/firebase/messaging/MessageTest.java @@ -29,11 +29,8 @@ import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.HashMap; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.Test; @@ -94,7 +91,10 @@ public void testPrefixedTopicName() throws IOException { @Test public void testNotificationMessageDeprecatedConstructor() throws IOException { Message message = Message.builder() - .setNotification(new Notification("title", "body")) + .setNotification(Notification.builder() + .setTitle("title") + .setBody("body") + .build()) .setTopic("test-topic") .build(); Map data = ImmutableMap.of("title", "title", "body", "body"); @@ -729,7 +729,11 @@ public void testIncorrectAnalyticsLabelFormat() { @Test public void testImageInNotificationDeprecatedConstructor() throws IOException { Message message = Message.builder() - .setNotification(new Notification("title", "body", TEST_IMAGE_URL)) + .setNotification(Notification.builder() + .setTitle("title") + .setBody("body") + .setImage(TEST_IMAGE_URL) + .build()) .setTopic("test-topic") .build(); Map data = ImmutableMap.of( @@ -755,7 +759,11 @@ public void testImageInNotification() throws IOException { @Test public void testImageInAndroidNotification() throws IOException { Message message = Message.builder() - .setNotification(new Notification("title", "body", TEST_IMAGE_URL)) + .setNotification(Notification.builder() + .setTitle("title") + .setBody("body") + .setImage(TEST_IMAGE_URL) + .build()) .setAndroidConfig(AndroidConfig.builder() .setNotification(AndroidNotification.builder() .setTitle("android-title") @@ -785,7 +793,11 @@ public void testImageInAndroidNotification() throws IOException { public void testImageInApnsNotification() throws IOException { Message message = Message.builder() .setTopic("test-topic") - .setNotification(new Notification("title", "body", TEST_IMAGE_URL)) + .setNotification(Notification.builder() + .setTitle("title") + .setBody("body") + .setImage(TEST_IMAGE_URL) + .build()) .setApnsConfig( ApnsConfig.builder().setAps(Aps.builder().build()) .setFcmOptions(ApnsFcmOptions.builder().setImage(TEST_IMAGE_URL_APNS).build()) @@ -812,7 +824,7 @@ public void testImageInApnsNotification() throws IOException { } @Test - public void testInvalidColorInAndroidNotificationLightSettings() throws IOException { + public void testInvalidColorInAndroidNotificationLightSettings() { try { LightSettings.Builder lightSettingsBuilder = LightSettings.builder() .setColorFromString("#01020K") @@ -830,7 +842,10 @@ public void testInvalidColorInAndroidNotificationLightSettings() throws IOExcept public void testExtendedAndroidNotificationParameters() throws IOException { long[] vibrateTimings = {1000L, 1001L}; Message message = Message.builder() - .setNotification(new Notification("title", "body")) + .setNotification(Notification.builder() + .setTitle("title") + .setBody("body") + .build()) .setAndroidConfig(AndroidConfig.builder() .setNotification(AndroidNotification.builder() .setTitle("android-title") diff --git a/src/test/java/com/google/firebase/messaging/MulticastMessageTest.java b/src/test/java/com/google/firebase/messaging/MulticastMessageTest.java index 25018ed4c..83b751c64 100644 --- a/src/test/java/com/google/firebase/messaging/MulticastMessageTest.java +++ b/src/test/java/com/google/firebase/messaging/MulticastMessageTest.java @@ -38,7 +38,10 @@ public class MulticastMessageTest { private static final WebpushConfig WEBPUSH = WebpushConfig.builder() .putData("key", "value") .build(); - private static final Notification NOTIFICATION = new Notification("title", "body"); + private static final Notification NOTIFICATION = Notification.builder() + .setTitle("title") + .setBody("body") + .build(); @Test public void testMulticastMessage() { diff --git a/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementServiceImplTest.java b/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementServiceImplTest.java index 075a2600a..0c4cfca87 100644 --- a/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementServiceImplTest.java +++ b/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementServiceImplTest.java @@ -1043,7 +1043,7 @@ public void testAuthAndRetriesSupport() throws Exception { List mockResponses = ImmutableList.of( new MockLowLevelHttpResponse().setContent("{}")); MockHttpTransport transport = new MultiRequestMockHttpTransport(mockResponses); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId(PROJECT_ID) .setHttpTransport(transport) @@ -1066,7 +1066,7 @@ public void testHttpRetries() throws Exception { firstRpcResponse.setStatusCode(503).setContent("{}"), new MockLowLevelHttpResponse().setContent("{}")); MockHttpTransport transport = new MultiRequestMockHttpTransport(mockResponses); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId(PROJECT_ID) .setHttpTransport(transport) @@ -1094,7 +1094,7 @@ private static FirebaseProjectManagementServiceImpl initServiceImpl( List mockResponses, MultiRequestTestResponseInterceptor interceptor) { MockHttpTransport transport = new MultiRequestMockHttpTransport(mockResponses); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId(PROJECT_ID) .setHttpTransport(transport) @@ -1108,7 +1108,7 @@ private static FirebaseProjectManagementServiceImpl initServiceImpl( } private static FirebaseProjectManagementServiceImpl initServiceImplWithFaultyTransport() { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId(PROJECT_ID) .setHttpTransport(TestUtils.createFaultyHttpTransport()) diff --git a/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementTest.java b/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementTest.java index bb83ce190..30fcc3344 100644 --- a/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementTest.java +++ b/src/test/java/com/google/firebase/projectmanagement/FirebaseProjectManagementTest.java @@ -68,7 +68,7 @@ public class FirebaseProjectManagementTest { @BeforeClass public static void setUpClass() { - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(new MockGoogleCredentials("test-token")) .setProjectId(TEST_PROJECT_ID) .build(); diff --git a/src/test/java/com/google/firebase/snippets/FirebaseAppSnippets.java b/src/test/java/com/google/firebase/snippets/FirebaseAppSnippets.java index ed1ad464e..bf3d4ca6b 100644 --- a/src/test/java/com/google/firebase/snippets/FirebaseAppSnippets.java +++ b/src/test/java/com/google/firebase/snippets/FirebaseAppSnippets.java @@ -33,7 +33,7 @@ public void initializeWithServiceAccount() throws IOException { // [START initialize_sdk_with_service_account] FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json"); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) .setDatabaseUrl("https://.firebaseio.com/") .build(); @@ -44,7 +44,7 @@ public void initializeWithServiceAccount() throws IOException { public void initializeWithDefaultCredentials() throws IOException { // [START initialize_sdk_with_application_default] - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .setDatabaseUrl("https://.firebaseio.com/") .build(); @@ -57,7 +57,7 @@ public void initializeWithRefreshToken() throws IOException { // [START initialize_sdk_with_refresh_token] FileInputStream refreshToken = new FileInputStream("path/to/refreshToken.json"); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(refreshToken)) .setDatabaseUrl("https://.firebaseio.com/") .build(); @@ -73,7 +73,7 @@ public void initializeWithDefaultConfig() { } public void initializeDefaultApp() throws IOException { - FirebaseOptions defaultOptions = new FirebaseOptions.Builder() + FirebaseOptions defaultOptions = FirebaseOptions.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .build(); @@ -94,10 +94,10 @@ public void initializeDefaultApp() throws IOException { } public void initializeCustomApp() throws Exception { - FirebaseOptions defaultOptions = new FirebaseOptions.Builder() + FirebaseOptions defaultOptions = FirebaseOptions.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .build(); - FirebaseOptions otherAppConfig = new FirebaseOptions.Builder() + FirebaseOptions otherAppConfig = FirebaseOptions.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .build(); @@ -123,7 +123,7 @@ public void initializeCustomApp() throws Exception { public void initializeWithServiceAccountId() throws IOException { // [START initialize_sdk_with_service_account_id] - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.getApplicationDefault()) .setServiceAccountId("my-client-id@my-project-id.iam.gserviceaccount.com") .build(); diff --git a/src/test/java/com/google/firebase/snippets/FirebaseDatabaseSnippets.java b/src/test/java/com/google/firebase/snippets/FirebaseDatabaseSnippets.java index baf4d3b69..079946649 100644 --- a/src/test/java/com/google/firebase/snippets/FirebaseDatabaseSnippets.java +++ b/src/test/java/com/google/firebase/snippets/FirebaseDatabaseSnippets.java @@ -677,7 +677,7 @@ public void initializeApp() throws IOException { FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccount.json"); // Initialize the app with a service account, granting admin privileges - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) .setDatabaseUrl("https://.firebaseio.com") .build(); diff --git a/src/test/java/com/google/firebase/snippets/FirebaseMessagingSnippets.java b/src/test/java/com/google/firebase/snippets/FirebaseMessagingSnippets.java index d6e4417e1..f1432e160 100644 --- a/src/test/java/com/google/firebase/snippets/FirebaseMessagingSnippets.java +++ b/src/test/java/com/google/firebase/snippets/FirebaseMessagingSnippets.java @@ -88,9 +88,10 @@ public void sendToCondition() throws FirebaseMessagingException { // See documentation on defining a message payload. Message message = Message.builder() - .setNotification(new Notification( - "$GOOG up 1.43% on the day", - "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.")) + .setNotification(Notification.builder() + .setTitle("$GOOG up 1.43% on the day") + .setBody("$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.") + .build()) .setCondition(condition) .build(); @@ -125,12 +126,18 @@ public void sendAll() throws FirebaseMessagingException { // Create a list containing up to 500 messages. List messages = Arrays.asList( Message.builder() - .setNotification(new Notification("Price drop", "5% off all electronics")) + .setNotification(Notification.builder() + .setTitle("Price drop") + .setBody("5% off all electronics") + .build()) .setToken(registrationToken) .build(), // ... Message.builder() - .setNotification(new Notification("Price drop", "2% off all books")) + .setNotification(Notification.builder() + .setTitle("Price drop") + .setBody("2% off all books") + .build()) .setTopic("readers-club") .build() ); @@ -251,9 +258,10 @@ public Message webpushMessage() { public Message allPlatformsMessage() { // [START multi_platforms_message] Message message = Message.builder() - .setNotification(new Notification( - "$GOOG up 1.43% on the day", - "$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.")) + .setNotification(Notification.builder() + .setTitle("$GOOG up 1.43% on the day") + .setBody("$GOOG gained 11.80 points to close at 835.67, up 1.43% on the day.") + .build()) .setAndroidConfig(AndroidConfig.builder() .setTtl(3600 * 1000) .setNotification(AndroidNotification.builder() diff --git a/src/test/java/com/google/firebase/snippets/FirebaseStorageSnippets.java b/src/test/java/com/google/firebase/snippets/FirebaseStorageSnippets.java index 380dcff1b..706cc1b16 100644 --- a/src/test/java/com/google/firebase/snippets/FirebaseStorageSnippets.java +++ b/src/test/java/com/google/firebase/snippets/FirebaseStorageSnippets.java @@ -33,7 +33,7 @@ public void initializeAppForStorage() throws IOException { // [START init_admin_sdk_for_storage] FileInputStream serviceAccount = new FileInputStream("path/to/serviceAccountKey.json"); - FirebaseOptions options = new FirebaseOptions.Builder() + FirebaseOptions options = FirebaseOptions.builder() .setCredentials(GoogleCredentials.fromStream(serviceAccount)) .setStorageBucket(".appspot.com") .build(); diff --git a/src/test/java/com/google/firebase/testing/IntegrationTestUtils.java b/src/test/java/com/google/firebase/testing/IntegrationTestUtils.java index d3abaa096..0e801f005 100644 --- a/src/test/java/com/google/firebase/testing/IntegrationTestUtils.java +++ b/src/test/java/com/google/firebase/testing/IntegrationTestUtils.java @@ -121,7 +121,7 @@ public static synchronized FirebaseApp ensureDefaultApp() { public static FirebaseApp initApp(String name) { FirebaseOptions options = - new FirebaseOptions.Builder() + FirebaseOptions.builder() .setDatabaseUrl(getDatabaseUrl()) .setCredentials(TestUtils.getCertCredential(getServiceAccountCertificate())) .build();