Search in sources :

Example 6 with DatabaseId

use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.

the class PersistenceTestHelpers method openSQLitePersistence.

private static SQLitePersistence openSQLitePersistence(String name, LruGarbageCollector.Params params) {
    DatabaseId databaseId = DatabaseId.forProject("projectId");
    LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
    Context context = ApplicationProvider.getApplicationContext();
    SQLitePersistence persistence = new SQLitePersistence(context, name, databaseId, serializer, params);
    persistence.start();
    return persistence;
}
Also used : Context(android.content.Context) RemoteSerializer(com.google.firebase.firestore.remote.RemoteSerializer) DatabaseId(com.google.firebase.firestore.model.DatabaseId)

Example 7 with DatabaseId

use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.

the class UserDataWriter method convertReference.

private Object convertReference(Value value) {
    DatabaseId refDatabase = DatabaseId.fromName(value.getReferenceValue());
    DocumentKey key = DocumentKey.fromName(value.getReferenceValue());
    DatabaseId database = firestore.getDatabaseId();
    if (!refDatabase.equals(database)) {
        // TODO: Somehow support foreign references.
        Logger.warn("DocumentSnapshot", "Document %s contains a document reference within a different database " + "(%s/%s) which is not supported. It will be treated as a reference in " + "the current database (%s/%s) instead.", key.getPath(), refDatabase.getProjectId(), refDatabase.getDatabaseId(), database.getProjectId(), database.getDatabaseId());
    }
    return new DocumentReference(key, firestore);
}
Also used : DocumentKey(com.google.firebase.firestore.model.DocumentKey) DatabaseId(com.google.firebase.firestore.model.DatabaseId)

Example 8 with DatabaseId

use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.

the class UserDataWriterTest method testConvertsResourceName.

@Test
public void testConvertsResourceName() {
    DatabaseId id = DatabaseId.forProject("project");
    List<DocumentReference> testCases = asList(ref("foo/bar"), ref("foo/baz"));
    for (DocumentReference docRef : testCases) {
        Value value = wrap(docRef);
        assertTrue(Values.isReferenceValue(value));
        assertEquals(TestAccessHelper.referenceKey(docRef), DocumentKey.fromName(value.getReferenceValue()));
        assertEquals(id, DatabaseId.fromName(value.getReferenceValue()));
    }
}
Also used : ObjectValue(com.google.firebase.firestore.model.ObjectValue) Value(com.google.firestore.v1.Value) ArrayValue(com.google.firestore.v1.ArrayValue) DatabaseId(com.google.firebase.firestore.model.DatabaseId) Test(org.junit.Test)

Example 9 with DatabaseId

use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.

the class LocalSerializerTest method setUp.

@Before
public void setUp() {
    DatabaseId databaseId = DatabaseId.forDatabase("p", "d");
    remoteSerializer = new RemoteSerializer(databaseId);
    serializer = new LocalSerializer(remoteSerializer);
}
Also used : RemoteSerializer(com.google.firebase.firestore.remote.RemoteSerializer) DatabaseId(com.google.firebase.firestore.model.DatabaseId) Before(org.junit.Before)

Example 10 with DatabaseId

use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.

the class TestUtil method wrap.

public static Value wrap(Object value) {
    DatabaseId databaseId = DatabaseId.forProject("project");
    UserDataReader dataReader = new UserDataReader(databaseId);
    // our tests currently use wrap() pretty generically so we don't know the intent.
    return dataReader.parseQueryValue(value);
}
Also used : UserDataReader(com.google.firebase.firestore.UserDataReader) DatabaseId(com.google.firebase.firestore.model.DatabaseId)

Aggregations

DatabaseId (com.google.firebase.firestore.model.DatabaseId)10 RemoteSerializer (com.google.firebase.firestore.remote.RemoteSerializer)5 Context (android.content.Context)3 AsyncQueue (com.google.firebase.firestore.util.AsyncQueue)2 NonNull (androidx.annotation.NonNull)1 FirebaseFirestore (com.google.firebase.firestore.FirebaseFirestore)1 UserDataReader (com.google.firebase.firestore.UserDataReader)1 FirebaseAppCheckTokenProvider (com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider)1 FirebaseAuthCredentialsProvider (com.google.firebase.firestore.auth.FirebaseAuthCredentialsProvider)1 User (com.google.firebase.firestore.auth.User)1 MemoryComponentProvider (com.google.firebase.firestore.core.MemoryComponentProvider)1 LocalSerializer (com.google.firebase.firestore.local.LocalSerializer)1 DocumentKey (com.google.firebase.firestore.model.DocumentKey)1 ObjectValue (com.google.firebase.firestore.model.ObjectValue)1 ArrayValue (com.google.firestore.v1.ArrayValue)1 Value (com.google.firestore.v1.Value)1 Before (org.junit.Before)1 Test (org.junit.Test)1