use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class EncodedPathTest method assertEncoded.
private void assertEncoded(String expected, ResourcePath path) {
String encoded = EncodedPath.encode(path);
assertEquals(expected, encoded);
ResourcePath decoded = EncodedPath.decodeResourcePath(encoded);
assertEquals(path, decoded);
// Verify that the value round trips through the SQLite API too.
db.execSQL("INSERT INTO keys VALUES (?)", new String[] { encoded });
Cursor cursor = db.rawQuery("SELECT key FROM keys WHERE key = ?", new String[] { encoded });
try {
assertTrue(cursor.moveToNext());
assertEquals(expected, cursor.getString(0));
} finally {
cursor.close();
}
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class QueryTest method testMatchesShallowAncestorQuery.
@Test
public void testMatchesShallowAncestorQuery() {
ResourcePath queryPath = ResourcePath.fromString("rooms/eros/messages");
MutableDocument doc1 = doc("rooms/eros/messages/1", 0, map("text", "msg1"));
MutableDocument doc1meta = doc("rooms/eros/messages/1/meta/1", 0, map("meta", "meta-value"));
MutableDocument doc2 = doc("rooms/eros/messages/2", 0, map("text", "msg2"));
MutableDocument doc3 = doc("rooms/other/messages/1", 0, map("text", "msg3"));
Query query = Query.atPath(queryPath);
assertTrue(query.matches(doc1));
assertFalse(query.matches(doc1meta));
assertTrue(query.matches(doc2));
assertFalse(query.matches(doc3));
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class QueryTest method testEmptyFieldsAreAllowedForQueries.
@Test
public void testEmptyFieldsAreAllowedForQueries() {
ResourcePath queryPath = ResourcePath.fromString("rooms/eros/messages");
MutableDocument doc1 = doc("rooms/eros/messages/1", 0, map("text", "msg1"));
MutableDocument doc2 = doc("rooms/eros/messages/2", 0, map());
Query query = Query.atPath(queryPath).filter(filter("text", "==", "msg1"));
assertTrue(query.matches(doc1));
assertFalse(query.matches(doc2));
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromUsesReadTimeNotUpdateTime.
@Test
public void testGetAllFromUsesReadTimeNotUpdateTime() {
addTestDocumentAtPath("b/old", /* updateTime= */
1, /* readTime= */
2);
addTestDocumentAtPath("b/new", /* updateTime= */
2, /* readTime= */
1);
ResourcePath collection = path("b");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.createSuccessor(version(1), -1));
assertThat(results.values()).containsExactly(doc("b/old", 1, DOC_DATA));
}
use of com.google.firebase.firestore.model.ResourcePath in project firebase-android-sdk by firebase.
the class RemoteDocumentCacheTestCase method testGetAllFromExcludesSubcollections.
@Test
public void testGetAllFromExcludesSubcollections() {
addTestDocumentAtPath("a/1");
addTestDocumentAtPath("a/1/b/1");
addTestDocumentAtPath("a/2");
ResourcePath collection = path("a");
Map<DocumentKey, MutableDocument> results = remoteDocumentCache.getAll(collection, IndexOffset.NONE);
assertThat(results.values()).containsExactly(doc("a/1", 42, DOC_DATA), doc("a/2", 42, DOC_DATA));
}
Aggregations