Skip to content

Commit d302558

Browse files
authored
Fixing some deprecation warnings (#380)
1 parent b785e02 commit d302558

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

src/test/java/com/google/firebase/FirebaseOptionsTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
package com.google.firebase;
1818

1919
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertFalse;
20+
import static org.junit.Assert.assertNotEquals;
2121
import static org.junit.Assert.assertNotNull;
2222
import static org.junit.Assert.assertNotSame;
2323
import static org.junit.Assert.assertNull;
2424
import static org.junit.Assert.assertSame;
2525
import static org.junit.Assert.assertTrue;
2626

27-
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
2827
import com.google.api.client.http.javanet.NetHttpTransport;
2928
import com.google.api.client.json.gson.GsonFactory;
3029
import com.google.auth.oauth2.AccessToken;
@@ -76,9 +75,7 @@ protected ThreadFactory getThreadFactory() {
7675
public void createOptionsWithAllValuesSet() throws IOException {
7776
GsonFactory jsonFactory = new GsonFactory();
7877
NetHttpTransport httpTransport = new NetHttpTransport();
79-
FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder()
80-
.setTimestampsInSnapshotsEnabled(true)
81-
.build();
78+
FirestoreOptions firestoreOptions = FirestoreOptions.newBuilder().build();
8279
FirebaseOptions firebaseOptions =
8380
new FirebaseOptions.Builder()
8481
.setDatabaseUrl(FIREBASE_DB_URL)
@@ -106,7 +103,7 @@ public void createOptionsWithAllValuesSet() throws IOException {
106103
assertNotNull(credentials);
107104
assertTrue(credentials instanceof ServiceAccountCredentials);
108105
assertEquals(
109-
GoogleCredential.fromStream(ServiceAccount.EDITOR.asStream()).getServiceAccountId(),
106+
ServiceAccount.EDITOR.getEmail(),
110107
((ServiceAccountCredentials) credentials).getClientEmail());
111108
}
112109

@@ -128,7 +125,7 @@ public void createOptionsWithOnlyMandatoryValuesSet() throws IOException {
128125
assertNotNull(credentials);
129126
assertTrue(credentials instanceof ServiceAccountCredentials);
130127
assertEquals(
131-
GoogleCredential.fromStream(ServiceAccount.EDITOR.asStream()).getServiceAccountId(),
128+
ServiceAccount.EDITOR.getEmail(),
132129
((ServiceAccountCredentials) credentials).getClientEmail());
133130
assertNull(firebaseOptions.getFirestoreOptions());
134131
}
@@ -224,6 +221,6 @@ public void testNotEquals() throws IOException {
224221
.setCredentials(credentials)
225222
.setDatabaseUrl("https://test.firebaseio.com")
226223
.build();
227-
assertFalse(options1.equals(options2));
224+
assertNotEquals(options1, options2);
228225
}
229226
}

src/test/java/com/google/firebase/database/utilities/ValidationTest.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
import static org.junit.Assert.fail;
2020

21+
import com.google.common.collect.ImmutableList;
2122
import com.google.common.collect.ImmutableMap;
2223
import com.google.firebase.database.DatabaseException;
2324
import com.google.firebase.database.core.Path;
25+
import java.util.List;
2426
import java.util.Map;
2527
import org.junit.Test;
2628

@@ -144,32 +146,32 @@ public void testNonWritablePath() {
144146

145147
@Test
146148
public void testUpdate() {
147-
Map[] updates = new Map[]{
148-
ImmutableMap.of("foo", "value"),
149-
ImmutableMap.of("foo", ""),
150-
ImmutableMap.of("foo", 10D),
151-
ImmutableMap.of(".foo", "foo"),
152-
ImmutableMap.of("foo", "value", "bar", "value"),
153-
};
149+
List<Map<String, Object>> updates = ImmutableList.<Map<String, Object>>of(
150+
ImmutableMap.<String, Object>of("foo", "value"),
151+
ImmutableMap.<String, Object>of("foo", ""),
152+
ImmutableMap.<String, Object>of("foo", 10D),
153+
ImmutableMap.<String, Object>of(".foo", "foo"),
154+
ImmutableMap.<String, Object>of("foo", "value", "bar", "value")
155+
);
154156
Path path = new Path("path");
155-
for (Map map : updates) {
157+
for (Map<String, Object> map : updates) {
156158
Validation.parseAndValidateUpdate(path, map);
157159
}
158160
}
159161

160162
@Test
161163
public void testInvalidUpdate() {
162-
Map[] invalidUpdates = new Map[]{
163-
ImmutableMap.of(".sv", "foo"),
164-
ImmutableMap.of(".value", "foo"),
165-
ImmutableMap.of(".priority", ImmutableMap.of("a", "b")),
166-
ImmutableMap.of("foo", "value", "foo/bar", "value"),
167-
ImmutableMap.of("foo", Double.POSITIVE_INFINITY),
168-
ImmutableMap.of("foo", Double.NEGATIVE_INFINITY),
169-
ImmutableMap.of("foo", Double.NaN),
170-
};
164+
List<Map<String, Object>> invalidUpdates = ImmutableList.<Map<String, Object>>of(
165+
ImmutableMap.<String, Object>of(".sv", "foo"),
166+
ImmutableMap.<String, Object>of(".value", "foo"),
167+
ImmutableMap.<String, Object>of(".priority", ImmutableMap.of("a", "b")),
168+
ImmutableMap.<String, Object>of("foo", "value", "foo/bar", "value"),
169+
ImmutableMap.<String, Object>of("foo", Double.POSITIVE_INFINITY),
170+
ImmutableMap.<String, Object>of("foo", Double.NEGATIVE_INFINITY),
171+
ImmutableMap.<String, Object>of("foo", Double.NaN)
172+
);
171173
Path path = new Path("path");
172-
for (Map map : invalidUpdates) {
174+
for (Map<String, Object> map : invalidUpdates) {
173175
try {
174176
Validation.parseAndValidateUpdate(path, map);
175177
fail("No error thrown for invalid update: " + map);

0 commit comments

Comments
 (0)