Skip to content

Commit 08ecaa8

Browse files
authored
Add missing test annotation and ErrorProne suggestions. (#1558)
* Add missing test annotation and ErrorProne suggestions. * AssertTrue instead
1 parent 631484a commit 08ecaa8

File tree

7 files changed

+10
-28
lines changed

7 files changed

+10
-28
lines changed

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/FirestoreTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void testCanUpdateAnUnknownDocument() {
9898
fail("Should have thrown exception");
9999
} catch (RuntimeException e) {
100100
assertEquals(
101-
((FirebaseFirestoreException) e.getCause().getCause()).getCode(), Code.UNAVAILABLE);
101+
Code.UNAVAILABLE, ((FirebaseFirestoreException) e.getCause().getCause()).getCode());
102102
}
103103
writerSnap = waitFor(writerRef.get());
104104
assertEquals(map("a", "a", "b", "b"), writerSnap.getData());
@@ -1060,7 +1060,7 @@ public void testMaintainsPersistenceAfterRestarting() {
10601060
testFirestore(provider().projectId(), Level.DEBUG, newTestSettings(), "dbPersistenceKey");
10611061
DocumentReference docRef2 = firestore2.document(docRef.getPath());
10621062
DocumentSnapshot doc = waitFor(docRef2.get());
1063-
assertEquals(doc.exists(), true);
1063+
assertTrue(doc.exists());
10641064
}
10651065

10661066
@Test
@@ -1112,7 +1112,7 @@ public void testRestartFirestoreLeadsToNewInstance() {
11121112

11131113
// Verify new instance works.
11141114
DocumentSnapshot doc = waitFor(newInstance.document("abc/123").get());
1115-
assertEquals(doc.get("field"), 100L);
1115+
assertEquals(100L, doc.get("field"));
11161116
waitFor(newInstance.document("abc/123").delete());
11171117

11181118
// Verify it is different instance.
@@ -1233,7 +1233,6 @@ public void testWaitForPendingWritesFailsWhenUserChanges() {
12331233
public void testPendingWriteTaskResolveWhenOfflineIfThereIsNoPending() {
12341234
DocumentReference documentReference = testCollection("abc").document("123");
12351235
FirebaseFirestore firestore = documentReference.getFirestore();
1236-
Map<String, Object> data = map("foo", "bar");
12371236

12381237
// Prevent pending writes receiving acknowledgement.
12391238
waitFor(firestore.disableNetwork());

firebase-firestore/src/androidTest/java/com/google/firebase/firestore/ValidationTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -779,16 +779,6 @@ private static void expectWriteSuccess(Object data) {
779779
expectWriteSuccess(data, /*includeSets=*/ true, /*includeUpdates=*/ true);
780780
}
781781

782-
/** Performs a write using each update API and makes sure it succeeds. */
783-
private static void expectUpdateSuccess(Map<String, Object> data) {
784-
expectWriteSuccess(data, /*includeSets=*/ false, /*includeUpdates=*/ true);
785-
}
786-
787-
/** Performs a write using each set API and makes sure it succeeds. */
788-
private static void expectSetSuccess(Object data) {
789-
expectWriteSuccess(data, /*includeSets=*/ true, /*includeUpdates=*/ false);
790-
}
791-
792782
/**
793783
* Performs a write using each set and/or update API and makes sure it fails with the expected
794784
* reason.

firebase-firestore/src/test/java/com/google/firebase/firestore/local/IndexedQueryEngineTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public void setUp() {
6565

6666
SQLitePersistence persistence = PersistenceTestHelpers.createSQLitePersistence();
6767
SQLiteCollectionIndex index = new SQLiteCollectionIndex(persistence, User.UNAUTHENTICATED);
68-
MutationQueue mutationQueue = persistence.getMutationQueue(User.UNAUTHENTICATED);
6968
remoteDocuments = persistence.getRemoteDocumentCache();
7069
queryEngine = new IndexedQueryEngine(index);
7170
}

firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ public void rewritesCanonicalIds() {
562562
Target targetProto = Target.parseFrom(targetProtoBytes);
563563
TargetData targetData = serializer.decodeTargetData(targetProto);
564564
String expectedCanonicalId = targetData.getTarget().getCanonicalId();
565-
assertEquals(actualCanonicalId, expectedCanonicalId);
565+
assertEquals(expectedCanonicalId, actualCanonicalId);
566566
} catch (InvalidProtocolBufferException e) {
567567
fail("Failed to decode Target data");
568568
}

firebase-firestore/src/test/java/com/google/firebase/firestore/model/ValuesTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@
3333
import java.util.Date;
3434
import java.util.TimeZone;
3535
import org.junit.Test;
36+
import org.junit.runner.RunWith;
37+
import org.robolectric.RobolectricTestRunner;
38+
import org.robolectric.annotation.Config;
3639

40+
@RunWith(RobolectricTestRunner.class)
41+
@Config(manifest = Config.NONE)
3742
public class ValuesTest {
3843
private final Date date1;
3944
private final Date date2;

firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/ComparatorTester.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
* @author [email protected] (Ben Maurer)
7171
*/
7272
public class ComparatorTester {
73-
@SuppressWarnings({"unchecked", "rawtypes"})
73+
@SuppressWarnings({"rawtypes"})
7474
private final @Nullable Comparator comparator;
7575

7676
/** The items that we are checking, stored as a sorted set of equivalence classes. */
@@ -192,7 +192,6 @@ private void testNullCompare(Object obj) {
192192
}
193193
}
194194

195-
@SuppressWarnings("unchecked")
196195
private void testClassCast(Object obj) {
197196
if (comparator == null) {
198197
try {

firebase-firestore/src/testUtil/java/com/google/firebase/firestore/testutil/TestUtil.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static org.junit.Assert.assertNotEquals;
2121
import static org.junit.Assert.fail;
2222

23-
import androidx.annotation.NonNull;
2423
import com.fasterxml.jackson.core.type.TypeReference;
2524
import com.fasterxml.jackson.databind.ObjectMapper;
2625
import com.google.android.gms.common.internal.Preconditions;
@@ -556,15 +555,6 @@ public static ByteString resumeToken(long snapshotVersion) {
556555
return ByteString.copyFrom(snapshotString, Charsets.UTF_8);
557556
}
558557

559-
@NonNull
560-
private static ByteString resumeToken(SnapshotVersion snapshotVersion) {
561-
if (snapshotVersion.equals(SnapshotVersion.NONE)) {
562-
return ByteString.EMPTY;
563-
} else {
564-
return ByteString.copyFromUtf8(snapshotVersion.toString());
565-
}
566-
}
567-
568558
public static ByteString streamToken(String contents) {
569559
return ByteString.copyFrom(contents, Charsets.UTF_8);
570560
}

0 commit comments

Comments
 (0)