|
19 | 19 | import static org.junit.Assert.assertTrue;
|
20 | 20 | import static org.junit.Assert.fail;
|
21 | 21 |
|
| 22 | +import androidx.test.platform.app.InstrumentationRegistry; |
22 | 23 | import com.fasterxml.jackson.core.type.TypeReference;
|
23 | 24 | import com.fasterxml.jackson.databind.ObjectMapper;
|
24 | 25 | import com.google.firebase.FirebaseApp;
|
| 26 | +import com.google.firebase.FirebaseOptions; |
25 | 27 | import com.google.firebase.database.android.AndroidAppCheckTokenProvider;
|
26 | 28 | import com.google.firebase.database.android.AndroidAuthTokenProvider;
|
27 | 29 | import com.google.firebase.database.core.CompoundWrite;
|
@@ -342,6 +344,23 @@ public static DataSnapshot referenceAtPath(DatabaseReference node, EventRecord r
|
342 | 344 | return record.getSnapshot().child(node.getPath().toString());
|
343 | 345 | }
|
344 | 346 |
|
| 347 | + public static FirebaseApp appForDatabaseUrl(String url, String name) { |
| 348 | + return FirebaseApp.initializeApp( |
| 349 | + InstrumentationRegistry.getInstrumentation().getTargetContext(), |
| 350 | + new FirebaseOptions.Builder() |
| 351 | + .setApplicationId("appid") |
| 352 | + .setApiKey("apikey") |
| 353 | + .setDatabaseUrl(url) |
| 354 | + .build(), |
| 355 | + name); |
| 356 | + } |
| 357 | + |
| 358 | + public static FirebaseDatabase getNewDatabase() { |
| 359 | + FirebaseApp app = |
| 360 | + appForDatabaseUrl(IntegrationTestValues.getDatabaseUrl(), UUID.randomUUID().toString()); |
| 361 | + return FirebaseDatabase.getInstance(app); |
| 362 | + } |
| 363 | + |
345 | 364 | public static DataSnapshot getSnap(Query ref) throws InterruptedException {
|
346 | 365 |
|
347 | 366 | final Semaphore semaphore = new Semaphore(0);
|
|
0 commit comments