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;
}
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);
}
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()));
}
}
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);
}
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);
}
Aggregations