Skip to content

Add missing test annotation and ErrorProne suggestions. #1558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void testCanUpdateAnUnknownDocument() {
fail("Should have thrown exception");
} catch (RuntimeException e) {
assertEquals(
((FirebaseFirestoreException) e.getCause().getCause()).getCode(), Code.UNAVAILABLE);
Code.UNAVAILABLE, ((FirebaseFirestoreException) e.getCause().getCause()).getCode());
}
writerSnap = waitFor(writerRef.get());
assertEquals(map("a", "a", "b", "b"), writerSnap.getData());
Expand Down Expand Up @@ -1060,7 +1060,7 @@ public void testMaintainsPersistenceAfterRestarting() {
testFirestore(provider().projectId(), Level.DEBUG, newTestSettings(), "dbPersistenceKey");
DocumentReference docRef2 = firestore2.document(docRef.getPath());
DocumentSnapshot doc = waitFor(docRef2.get());
assertEquals(doc.exists(), true);
assertTrue(doc.exists());
}

@Test
Expand Down Expand Up @@ -1112,7 +1112,7 @@ public void testRestartFirestoreLeadsToNewInstance() {

// Verify new instance works.
DocumentSnapshot doc = waitFor(newInstance.document("abc/123").get());
assertEquals(doc.get("field"), 100L);
assertEquals(100L, doc.get("field"));
waitFor(newInstance.document("abc/123").delete());

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

// Prevent pending writes receiving acknowledgement.
waitFor(firestore.disableNetwork());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,16 +779,6 @@ private static void expectWriteSuccess(Object data) {
expectWriteSuccess(data, /*includeSets=*/ true, /*includeUpdates=*/ true);
}

/** Performs a write using each update API and makes sure it succeeds. */
private static void expectUpdateSuccess(Map<String, Object> data) {
expectWriteSuccess(data, /*includeSets=*/ false, /*includeUpdates=*/ true);
}

/** Performs a write using each set API and makes sure it succeeds. */
private static void expectSetSuccess(Object data) {
expectWriteSuccess(data, /*includeSets=*/ true, /*includeUpdates=*/ false);
}

/**
* Performs a write using each set and/or update API and makes sure it fails with the expected
* reason.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public void setUp() {

SQLitePersistence persistence = PersistenceTestHelpers.createSQLitePersistence();
SQLiteCollectionIndex index = new SQLiteCollectionIndex(persistence, User.UNAUTHENTICATED);
MutationQueue mutationQueue = persistence.getMutationQueue(User.UNAUTHENTICATED);
remoteDocuments = persistence.getRemoteDocumentCache();
queryEngine = new IndexedQueryEngine(index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public void rewritesCanonicalIds() {
Target targetProto = Target.parseFrom(targetProtoBytes);
TargetData targetData = serializer.decodeTargetData(targetProto);
String expectedCanonicalId = targetData.getTarget().getCanonicalId();
assertEquals(actualCanonicalId, expectedCanonicalId);
assertEquals(expectedCanonicalId, actualCanonicalId);
} catch (InvalidProtocolBufferException e) {
fail("Failed to decode Target data");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
import java.util.Date;
import java.util.TimeZone;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class ValuesTest {
private final Date date1;
private final Date date2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
* @author [email protected] (Ben Maurer)
*/
public class ComparatorTester {
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes"})
private final @Nullable Comparator comparator;

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

@SuppressWarnings("unchecked")
private void testClassCast(Object obj) {
if (comparator == null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.fail;

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

@NonNull
private static ByteString resumeToken(SnapshotVersion snapshotVersion) {
if (snapshotVersion.equals(SnapshotVersion.NONE)) {
return ByteString.EMPTY;
} else {
return ByteString.copyFromUtf8(snapshotVersion.toString());
}
}

public static ByteString streamToken(String contents) {
return ByteString.copyFrom(contents, Charsets.UTF_8);
}
Expand Down