use of androidx.sqlite.db.SupportSQLiteDatabase in project AmazeFileManager by TeamAmaze.
the class ExplorerDatabaseMigrationTest method migrateAll.
@Test
public void migrateAll() throws IOException {
SupportSQLiteDatabase db = helper.createDatabase(TEST_DB, 1);
db.close();
ExplorerDatabase explorerDatabase = Room.databaseBuilder(InstrumentationRegistry.getInstrumentation().getTargetContext(), ExplorerDatabase.class, TEST_DB).addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5, MIGRATION_5_6, MIGRATION_6_7).build();
explorerDatabase.getOpenHelper().getWritableDatabase();
explorerDatabase.close();
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project AmazeFileManager by TeamAmaze.
the class ExplorerDatabaseMigrationTest method migrateFromV7.
@Test
public void migrateFromV7() throws IOException {
SupportSQLiteDatabase db = helper.createDatabase(TEST_DB, 7);
db.execSQL("INSERT INTO " + TABLE_CLOUD_PERSIST + "(" + COLUMN_CLOUD_ID + "," + COLUMN_CLOUD_SERVICE + "," + COLUMN_CLOUD_PERSIST + ") VALUES (1," + (OpenMode.GDRIVE.ordinal() - 1) + ",'abcd')");
db.execSQL("INSERT INTO " + TABLE_CLOUD_PERSIST + "(" + COLUMN_CLOUD_ID + "," + COLUMN_CLOUD_SERVICE + "," + COLUMN_CLOUD_PERSIST + ") VALUES (2," + (OpenMode.DROPBOX.ordinal() - 1) + ",'efgh')");
db.execSQL("INSERT INTO " + TABLE_CLOUD_PERSIST + "(" + COLUMN_CLOUD_ID + "," + COLUMN_CLOUD_SERVICE + "," + COLUMN_CLOUD_PERSIST + ") VALUES (3," + (OpenMode.BOX.ordinal() - 1) + ",'ijkl')");
db.execSQL("INSERT INTO " + TABLE_CLOUD_PERSIST + "(" + COLUMN_CLOUD_ID + "," + COLUMN_CLOUD_SERVICE + "," + COLUMN_CLOUD_PERSIST + ") VALUES (4," + (OpenMode.ONEDRIVE.ordinal() - 1) + ",'mnop')");
db.close();
ExplorerDatabase explorerDatabase = Room.databaseBuilder(InstrumentationRegistry.getInstrumentation().getTargetContext(), ExplorerDatabase.class, TEST_DB).addMigrations(MIGRATION_7_8).allowMainThreadQueries().build();
explorerDatabase.getOpenHelper().getWritableDatabase();
CloudEntry verify = explorerDatabase.cloudEntryDao().findByServiceType(OpenMode.GDRIVE.ordinal()).subscribeOn(Schedulers.trampoline()).blockingGet();
assertEquals(1, verify.getId());
assertEquals("abcd", verify.getPersistData().toString());
verify = explorerDatabase.cloudEntryDao().findByServiceType(OpenMode.BOX.ordinal()).subscribeOn(Schedulers.trampoline()).blockingGet();
assertEquals(3, verify.getId());
assertEquals("ijkl", verify.getPersistData().toString());
verify = explorerDatabase.cloudEntryDao().findByServiceType(OpenMode.DROPBOX.ordinal()).subscribeOn(Schedulers.trampoline()).blockingGet();
assertEquals(2, verify.getId());
assertEquals("efgh", verify.getPersistData().toString());
verify = explorerDatabase.cloudEntryDao().findByServiceType(OpenMode.ONEDRIVE.ordinal()).subscribeOn(Schedulers.trampoline()).blockingGet();
assertEquals(4, verify.getId());
assertEquals("mnop", verify.getPersistData().toString());
explorerDatabase.close();
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project AmazeFileManager by TeamAmaze.
the class ExplorerDatabaseMigrationTest method migrateFromV5.
@Test
public void migrateFromV5() throws IOException {
SupportSQLiteDatabase db = helper.createDatabase(TEST_DB, 5);
db.close();
ExplorerDatabase explorerDatabase = Room.databaseBuilder(InstrumentationRegistry.getInstrumentation().getTargetContext(), ExplorerDatabase.class, TEST_DB).addMigrations(MIGRATION_5_6, MIGRATION_6_7).build();
explorerDatabase.getOpenHelper().getWritableDatabase();
explorerDatabase.close();
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project AmazeFileManager by TeamAmaze.
the class ExplorerDatabaseMigrationTest method migrateFromV6.
@Test
public void migrateFromV6() throws IOException {
SupportSQLiteDatabase db = helper.createDatabase(TEST_DB, 6);
db.close();
ExplorerDatabase explorerDatabase = Room.databaseBuilder(InstrumentationRegistry.getInstrumentation().getTargetContext(), ExplorerDatabase.class, TEST_DB).addMigrations(MIGRATION_6_7).build();
explorerDatabase.getOpenHelper().getWritableDatabase();
explorerDatabase.close();
}
use of androidx.sqlite.db.SupportSQLiteDatabase in project AmazeFileManager by TeamAmaze.
the class MigrationTestHelper method openDatabase.
private SupportSQLiteDatabase openDatabase(String name, RoomOpenHelper roomOpenHelper) {
SupportSQLiteOpenHelper.Configuration config = SupportSQLiteOpenHelper.Configuration.builder(mInstrumentation.getTargetContext()).callback(roomOpenHelper).name(name).build();
SupportSQLiteDatabase db = mOpenFactory.create(config).getWritableDatabase();
mManagedDatabases.add(new WeakReference<>(db));
return db;
}
Aggregations