use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testArrayContainsFilter.
@Test
public void testArrayContainsFilter() {
setUpArrayValueFilter();
Query query = query("coll").filter(filter("values", "array-contains", 1));
verifyResults(query, "coll/arr1");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testGreaterThanOrEqualsFilter.
@Test
public void testGreaterThanOrEqualsFilter() {
setUpSingleValueFilter();
Query query = query("coll").filter(filter("count", ">=", 2));
verifyResults(query, "coll/val2", "coll/val3");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testNoMatchingFilter.
@Test
public void testNoMatchingFilter() {
setUpSingleValueFilter();
Query query = query("coll").filter(filter("unknown", "==", true));
assertNull(indexManager.getFieldIndex(query.toTarget()));
assertNull(indexManager.getDocumentsMatchingTarget(query.toTarget()));
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteIndexManagerTest method testLessThanOrEqualsFilter.
@Test
public void testLessThanOrEqualsFilter() {
setUpSingleValueFilter();
Query query = query("coll").filter(filter("count", "<=", 2));
verifyResults(query, "coll/val1", "coll/val2");
}
use of com.google.firebase.firestore.core.Query in project firebase-android-sdk by firebase.
the class SQLiteTargetCacheTest method testMetadataPersistedAcrossRestarts.
@Test
public void testMetadataPersistedAcrossRestarts() {
String name = "test-targetCache-restarts";
SQLitePersistence db1 = PersistenceTestHelpers.createSQLitePersistence(name);
TargetCache targetCache1 = db1.getTargetCache();
assertEquals(0, targetCache1.getHighestListenSequenceNumber());
long originalSequenceNumber = 1234;
int targetId = 5;
SnapshotVersion snapshotVersion = new SnapshotVersion(new Timestamp(1, 2));
Query query = query("rooms");
TargetData targetData = new TargetData(query.toTarget(), targetId, originalSequenceNumber, QueryPurpose.LISTEN);
db1.runTransaction("add query data", () -> {
targetCache1.addTargetData(targetData);
targetCache1.setLastRemoteSnapshotVersion(snapshotVersion);
});
db1.shutdown();
SQLitePersistence db2 = PersistenceTestHelpers.createSQLitePersistence(name);
db2.runTransaction("verify sequence number", () -> {
long newSequenceNumber = db2.getReferenceDelegate().getCurrentSequenceNumber();
assertTrue(newSequenceNumber > originalSequenceNumber);
});
TargetCache targetCache2 = db2.getTargetCache();
assertEquals(targetId, targetCache2.getHighestTargetId());
assertEquals(snapshotVersion, targetCache2.getLastRemoteSnapshotVersion());
assertEquals(1, targetCache2.getTargetCount());
db2.shutdown();
}
Aggregations