use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testOrderByWithNotEqualsFilter.
@Test
public void testOrderByWithNotEqualsFilter() {
indexManager.addFieldIndex(fieldIndex("coll", "count", Kind.ASCENDING));
addDoc("coll/val1", map("count", 1));
addDoc("coll/val2", map("count", 2));
Query query = query("coll").filter(filter("count", "!=", 2)).orderBy(orderBy("count"));
verifyResults(query, "coll/val1");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testStartAfterFilter.
@Test
public void testStartAfterFilter() {
setUpSingleValueFilter();
Query query = query("coll").orderBy(orderBy("count")).startAt(bound(/* inclusive= */
false, 2));
verifyResults(query, "coll/val3");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testGreaterThanFilter.
@Test
public void testGreaterThanFilter() {
setUpSingleValueFilter();
Query query = query("coll").filter(filter("count", ">", 2));
verifyResults(query, "coll/val3");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testIndexEntriesAreUpdated.
@Test
public void testIndexEntriesAreUpdated() {
indexManager.addFieldIndex(fieldIndex("coll", "value", Kind.ASCENDING));
Query query = query("coll").orderBy(orderBy("value"));
addDoc("coll/doc1", map("value", true));
verifyResults(query, "coll/doc1");
addDocs(doc("coll/doc1", 1, map()), doc("coll/doc2", 1, map("value", true)));
verifyResults(query, "coll/doc2");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method verifyResults.
private void verifyResults(Query query, String... documents) {
Target target = query.toTarget();
Iterable<DocumentKey> results = indexManager.getDocumentsMatchingTarget(target);
assertNotNull("Target cannot be served from index.", results);
List<DocumentKey> keys = Arrays.stream(documents).map(s -> key(s)).collect(Collectors.toList());
assertWithMessage("Result for %s", query).that(results).containsExactlyElementsIn(keys);
}
Aggregations