use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.
the class IntegrationTestUtil method testFirestore.
public static FirebaseFirestore testFirestore(String projectId, Logger.Level logLevel, FirebaseFirestoreSettings settings, String persistenceKey) {
// This unfortunately is a global setting that affects existing Firestore clients.
Logger.setLogLevel(logLevel);
Context context = ApplicationProvider.getApplicationContext();
DatabaseId databaseId = DatabaseId.forDatabase(projectId, DatabaseId.DEFAULT_DATABASE_ID);
ensureStrictMode();
AsyncQueue asyncQueue = new AsyncQueue();
FirebaseFirestore firestore = AccessHelper.newFirebaseFirestore(context, databaseId, persistenceKey, MockCredentialsProvider.instance(), new EmptyAppCheckTokenProvider(), asyncQueue, /*firebaseApp=*/
null, /*instanceRegistry=*/
(dbId) -> {
});
waitFor(firestore.clearPersistence());
firestore.setFirestoreSettings(settings);
firestoreStatus.put(firestore, true);
return firestore;
}
use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.
the class FirebaseFirestore method newInstance.
@NonNull
static FirebaseFirestore newInstance(@NonNull Context context, @NonNull FirebaseApp app, @NonNull Deferred<InternalAuthProvider> deferredAuthProvider, @NonNull Deferred<InternalAppCheckTokenProvider> deferredAppCheckTokenProvider, @NonNull String database, @NonNull InstanceRegistry instanceRegistry, @Nullable GrpcMetadataProvider metadataProvider) {
String projectId = app.getOptions().getProjectId();
if (projectId == null) {
throw new IllegalArgumentException("FirebaseOptions.getProjectId() cannot be null");
}
DatabaseId databaseId = DatabaseId.forDatabase(projectId, database);
AsyncQueue queue = new AsyncQueue();
CredentialsProvider<User> authProvider = new FirebaseAuthCredentialsProvider(deferredAuthProvider);
CredentialsProvider<String> appCheckProvider = new FirebaseAppCheckTokenProvider(deferredAppCheckTokenProvider);
// Firestore uses a different database for each app name. Note that we don't use
// app.getPersistenceKey() here because it includes the application ID which is related
// to the project ID. We already include the project ID when resolving the database,
// so there is no need to include it in the persistence key.
String persistenceKey = app.getName();
FirebaseFirestore firestore = new FirebaseFirestore(context, databaseId, persistenceKey, authProvider, appCheckProvider, queue, app, instanceRegistry, metadataProvider);
return firestore;
}
use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.
the class MemorySpecTest method initializeComponentProvider.
@Override
protected MemoryComponentProvider initializeComponentProvider(ComponentProvider.Configuration configuration, boolean garbageCollectionEnabled) {
MemoryComponentProvider provider = new MemoryComponentProvider() {
@Override
protected Persistence createPersistence(Configuration configuration) {
if (garbageCollectionEnabled) {
return MemoryPersistence.createEagerGcMemoryPersistence();
} else {
DatabaseId databaseId = DatabaseId.forProject("projectId");
LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
return MemoryPersistence.createLruGcMemoryPersistence(LruGarbageCollector.Params.Default(), serializer);
}
}
};
provider.initialize(configuration);
return provider;
}
use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.
the class PersistenceTestHelpers method createLRUMemoryPersistence.
public static MemoryPersistence createLRUMemoryPersistence(LruGarbageCollector.Params params) {
DatabaseId databaseId = DatabaseId.forProject("projectId");
LocalSerializer serializer = new LocalSerializer(new RemoteSerializer(databaseId));
MemoryPersistence persistence = MemoryPersistence.createLruGcMemoryPersistence(params, serializer);
persistence.start();
return persistence;
}
use of com.google.firebase.firestore.model.DatabaseId in project firebase-android-sdk by firebase.
the class PersistenceTestHelpers method openSQLitePersistence.
private static SQLitePersistence openSQLitePersistence(int version, 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(serializer, params, new SQLitePersistence.OpenHelper(context, serializer, databaseName(name, databaseId), version));
persistence.start();
return persistence;
}
Aggregations