From ed23fbb6504a02fbbfac849a0cbc7e2ecb20798b Mon Sep 17 00:00:00 2001 From: hiranya911 Date: Tue, 18 Feb 2020 16:56:06 -0800 Subject: [PATCH] Fixing some deprecation warnings --- .../google/firebase/FirebaseOptionsTest.java | 13 +++---- .../database/utilities/ValidationTest.java | 38 ++++++++++--------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/test/java/com/google/firebase/FirebaseOptionsTest.java b/src/test/java/com/google/firebase/FirebaseOptionsTest.java index a3dac26fd..af7f9846d 100644 --- a/src/test/java/com/google/firebase/FirebaseOptionsTest.java +++ b/src/test/java/com/google/firebase/FirebaseOptionsTest.java @@ -17,14 +17,13 @@ package com.google.firebase; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.gson.GsonFactory; import com.google.auth.oauth2.AccessToken; @@ -76,9 +75,7 @@ protected ThreadFactory getThreadFactory() { public void createOptionsWithAllValuesSet() throws IOException { GsonFactory jsonFactory = new GsonFactory(); NetHttpTransport httpTransport = new NetHttpTransport(); - FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder() - .setTimestampsInSnapshotsEnabled(true) - .build(); + FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder().build(); FirebaseOptions firebaseOptions = new FirebaseOptions.Builder() .setDatabaseUrl(FIREBASE_DB_URL) @@ -106,7 +103,7 @@ public void createOptionsWithAllValuesSet() throws IOException { assertNotNull(credentials); assertTrue(credentials instanceof ServiceAccountCredentials); assertEquals( - GoogleCredential.fromStream(ServiceAccount.EDITOR.asStream()).getServiceAccountId(), + ServiceAccount.EDITOR.getEmail(), ((ServiceAccountCredentials) credentials).getClientEmail()); } @@ -128,7 +125,7 @@ public void createOptionsWithOnlyMandatoryValuesSet() throws IOException { assertNotNull(credentials); assertTrue(credentials instanceof ServiceAccountCredentials); assertEquals( - GoogleCredential.fromStream(ServiceAccount.EDITOR.asStream()).getServiceAccountId(), + ServiceAccount.EDITOR.getEmail(), ((ServiceAccountCredentials) credentials).getClientEmail()); assertNull(firebaseOptions.getFirestoreOptions()); } @@ -224,6 +221,6 @@ public void testNotEquals() throws IOException { .setCredentials(credentials) .setDatabaseUrl("https://test.firebaseio.com") .build(); - assertFalse(options1.equals(options2)); + assertNotEquals(options1, options2); } } diff --git a/src/test/java/com/google/firebase/database/utilities/ValidationTest.java b/src/test/java/com/google/firebase/database/utilities/ValidationTest.java index b9e32a851..3293f5d6d 100644 --- a/src/test/java/com/google/firebase/database/utilities/ValidationTest.java +++ b/src/test/java/com/google/firebase/database/utilities/ValidationTest.java @@ -18,9 +18,11 @@ import static org.junit.Assert.fail; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.firebase.database.DatabaseException; import com.google.firebase.database.core.Path; +import java.util.List; import java.util.Map; import org.junit.Test; @@ -144,32 +146,32 @@ public void testNonWritablePath() { @Test public void testUpdate() { - Map[] updates = new Map[]{ - ImmutableMap.of("foo", "value"), - ImmutableMap.of("foo", ""), - ImmutableMap.of("foo", 10D), - ImmutableMap.of(".foo", "foo"), - ImmutableMap.of("foo", "value", "bar", "value"), - }; + List> updates = ImmutableList.>of( + ImmutableMap.of("foo", "value"), + ImmutableMap.of("foo", ""), + ImmutableMap.of("foo", 10D), + ImmutableMap.of(".foo", "foo"), + ImmutableMap.of("foo", "value", "bar", "value") + ); Path path = new Path("path"); - for (Map map : updates) { + for (Map map : updates) { Validation.parseAndValidateUpdate(path, map); } } @Test public void testInvalidUpdate() { - Map[] invalidUpdates = new Map[]{ - ImmutableMap.of(".sv", "foo"), - ImmutableMap.of(".value", "foo"), - ImmutableMap.of(".priority", ImmutableMap.of("a", "b")), - ImmutableMap.of("foo", "value", "foo/bar", "value"), - ImmutableMap.of("foo", Double.POSITIVE_INFINITY), - ImmutableMap.of("foo", Double.NEGATIVE_INFINITY), - ImmutableMap.of("foo", Double.NaN), - }; + List> invalidUpdates = ImmutableList.>of( + ImmutableMap.of(".sv", "foo"), + ImmutableMap.of(".value", "foo"), + ImmutableMap.of(".priority", ImmutableMap.of("a", "b")), + ImmutableMap.of("foo", "value", "foo/bar", "value"), + ImmutableMap.of("foo", Double.POSITIVE_INFINITY), + ImmutableMap.of("foo", Double.NEGATIVE_INFINITY), + ImmutableMap.of("foo", Double.NaN) + ); Path path = new Path("path"); - for (Map map : invalidUpdates) { + for (Map map : invalidUpdates) { try { Validation.parseAndValidateUpdate(path, map); fail("No error thrown for invalid update: " + map);