### Question:
QuerySnapshot implements Iterable<QueryDocumentSnapshot> { @Override public boolean equals(@Nullable Object obj) { if (this == obj) { return true; } if (!(obj instanceof QuerySnapshot)) { return false; } QuerySnapshot other = (QuerySnapshot) obj; return firestore.equals(other.firestore) && originalQuery.equals(other.originalQuery) && snapshot.equals(other.snapshot) && metadata.equals(other.metadata); } QuerySnapshot(Query originalQuery, ViewSnapshot snapshot, FirebaseFirestore firestore); @NonNull Query getQuery(); @NonNull SnapshotMetadata getMetadata(); @NonNull List<DocumentChange> getDocumentChanges(); @NonNull List<DocumentChange> getDocumentChanges(@NonNull MetadataChanges metadataChanges); @NonNull List<DocumentSnapshot> getDocuments(); boolean isEmpty(); int size(); @Override @NonNull Iterator<QueryDocumentSnapshot> iterator(); @NonNull List<T> toObjects(@NonNull Class<T> clazz); @NonNull List<T> toObjects(
      @NonNull Class<T> clazz,
      @NonNull DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior); @Override boolean equals(@Nullable Object obj); @Override int hashCode();  }### Answer:
@Test public void testEquals() { ObjectValue firstValue = wrapObject("a", 1); ObjectValue secondValue = wrapObject("b", 1); QuerySnapshot foo = TestUtil.querySnapshot("foo", map(), map("a", firstValue), true, false); QuerySnapshot fooDup = TestUtil.querySnapshot("foo", map(), map("a", firstValue), true, false); QuerySnapshot differentPath = TestUtil.querySnapshot("bar", map(), map("a", firstValue), true, false); QuerySnapshot differentDoc = TestUtil.querySnapshot("foo", map(), map("a", secondValue), true, false); QuerySnapshot noPendingWrites = TestUtil.querySnapshot("foo", map(), map("a", firstValue), false, false); QuerySnapshot fromCache = TestUtil.querySnapshot("foo", map(), map("a", firstValue), true, true); assertEquals(foo, fooDup); assertNotEquals(foo, differentPath); assertNotEquals(foo, differentDoc); assertNotEquals(foo, noPendingWrites); assertNotEquals(foo, fromCache); assertEquals(foo.hashCode(), fooDup.hashCode()); assertNotEquals(foo.hashCode(), differentPath.hashCode()); assertNotEquals(foo.hashCode(), noPendingWrites.hashCode()); assertNotEquals(foo.hashCode(), fromCache.hashCode()); }