use of com.google.firebase.firestore.model.DocumentSet in project firebase-android-sdk by firebase.
the class QueryEngineTestCase method doesNotUseInitialResultsForLimitToLastQueryWithDocumentRemoval.
@Test
public void doesNotUseInitialResultsForLimitToLastQueryWithDocumentRemoval() throws Exception {
Query query = query("coll").filter(filter("matches", "==", true)).orderBy(orderBy("order", "desc")).limitToLast(1);
// While the backend would never add DocA to the set of remote keys, this allows us to easily
// simulate what would happen when a document no longer matches due to an out-of-band update.
addDocument(NON_MATCHING_DOC_A);
persistQueryMapping(NON_MATCHING_DOC_A.getKey());
addDocument(MATCHING_DOC_B);
DocumentSet docs = expectFullCollectionScan(() -> runQuery(query, LAST_LIMBO_FREE_SNAPSHOT));
assertEquals(docSet(query.comparator(), MATCHING_DOC_B), docs);
}
use of com.google.firebase.firestore.model.DocumentSet in project firebase-android-sdk by firebase.
the class QueryEngineTestCase method doesNotUseInitialResultsWithoutLimboFreeSnapshotVersion.
@Test
public void doesNotUseInitialResultsWithoutLimboFreeSnapshotVersion() throws Exception {
Query query = query("coll").filter(filter("matches", "==", true));
DocumentSet docs = expectFullCollectionScan(() -> runQuery(query, MISSING_LAST_LIMBO_FREE_SNAPSHOT));
assertEquals(docSet(query.comparator()), docs);
}
use of com.google.firebase.firestore.model.DocumentSet in project firebase-android-sdk by firebase.
the class QueryEngineTestCase method doesNotUseInitialResultsForLimitQueryWithDocumentRemoval.
@Test
public void doesNotUseInitialResultsForLimitQueryWithDocumentRemoval() throws Exception {
Query query = query("coll").filter(filter("matches", "==", true)).limitToFirst(1);
// While the backend would never add DocA to the set of remote keys, this allows us to easily
// simulate what would happen when a document no longer matches due to an out-of-band update.
addDocument(NON_MATCHING_DOC_A);
persistQueryMapping(NON_MATCHING_DOC_A.getKey());
addDocument(MATCHING_DOC_B);
DocumentSet docs = expectFullCollectionScan(() -> runQuery(query, LAST_LIMBO_FREE_SNAPSHOT));
assertEquals(docSet(query.comparator(), MATCHING_DOC_B), docs);
}
use of com.google.firebase.firestore.model.DocumentSet in project firebase-android-sdk by firebase.
the class QueryEngineTestCase method filtersNonMatchingInitialResults.
@Test
public void filtersNonMatchingInitialResults() throws Exception {
Query query = query("coll").filter(filter("matches", "==", true));
addDocument(MATCHING_DOC_A, MATCHING_DOC_B);
persistQueryMapping(MATCHING_DOC_A.getKey(), MATCHING_DOC_B.getKey());
// Add a mutated document that is not yet part of query's set of remote keys.
addDocumentWithEventVersion(version(1), NON_MATCHING_DOC_A);
DocumentSet docs = expectOptimizedCollectionScan(() -> runQuery(query, LAST_LIMBO_FREE_SNAPSHOT));
assertEquals(docSet(query.comparator(), MATCHING_DOC_B), docs);
}
use of com.google.firebase.firestore.model.DocumentSet in project firebase-android-sdk by firebase.
the class QueryEngineTestCase method doesNotUseInitialResultsForLimitQueryWhenLastDocumentHasBeenUpdatedOutOfBand.
@Test
public void doesNotUseInitialResultsForLimitQueryWhenLastDocumentHasBeenUpdatedOutOfBand() throws Exception {
Query query = query("coll").filter(filter("matches", "==", true)).orderBy(orderBy("order", "desc")).limitToFirst(1);
// Add a query mapping for a document that matches, but that sorts below another document based
// due to an update that the SDK received after the query's snapshot was persisted.
addDocument(UPDATED_DOC_A);
persistQueryMapping(UPDATED_DOC_A.getKey());
addDocument(MATCHING_DOC_B);
DocumentSet docs = expectFullCollectionScan(() -> runQuery(query, LAST_LIMBO_FREE_SNAPSHOT));
assertEquals(docSet(query.comparator(), MATCHING_DOC_B), docs);
}
Aggregations