Skip to content

Commit

Permalink
refactor: avoid spread operators
Browse files Browse the repository at this point in the history
  • Loading branch information
JuancaG05 committed Jan 27, 2025
1 parent 33c7853 commit 3493a1d
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@ package com.owncloud.android.data.roommigrations
import android.database.sqlite.SQLiteDatabase
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.test.filters.SmallTest
import com.owncloud.android.data.OwncloudDatabase
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.OCSHARES_TABLE_NAME
import com.owncloud.android.data.migrations.MIGRATION_27_28
import com.owncloud.android.data.migrations.MIGRATION_28_29
import com.owncloud.android.data.migrations.MIGRATION_29_30
import com.owncloud.android.data.migrations.MIGRATION_30_31
import com.owncloud.android.data.migrations.MIGRATION_31_32
import com.owncloud.android.data.migrations.MIGRATION_32_33
import com.owncloud.android.data.migrations.MIGRATION_33_34
import com.owncloud.android.data.migrations.MIGRATION_34_35
import com.owncloud.android.data.migrations.MIGRATION_35_36
import com.owncloud.android.data.migrations.MIGRATION_37_38
import com.owncloud.android.data.migrations.MIGRATION_41_42
import com.owncloud.android.data.migrations.MIGRATION_42_43
import com.owncloud.android.testutil.OC_SHARE
import org.junit.Assert.assertEquals
import org.junit.Test
Expand All @@ -43,7 +54,20 @@ class MigrationToDB29Test : MigrationTest() {
currentVersion = DB_VERSION_29,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo29(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand All @@ -54,7 +78,20 @@ class MigrationToDB29Test : MigrationTest() {
currentVersion = DB_VERSION_29,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo29(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase
import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.test.filters.SmallTest
import com.owncloud.android.data.OwncloudDatabase
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_ACCOUNT_NAME
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_CORE_POLLINTERVAL
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_DAV_CHUNKING_VERSION
Expand All @@ -33,6 +32,18 @@ import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_TAB
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.LEGACY_CAPABILITIES_VERSION_MAYOR
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_VERSION_MICRO
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_VERSION_MINOR
import com.owncloud.android.data.migrations.MIGRATION_27_28
import com.owncloud.android.data.migrations.MIGRATION_28_29
import com.owncloud.android.data.migrations.MIGRATION_29_30
import com.owncloud.android.data.migrations.MIGRATION_30_31
import com.owncloud.android.data.migrations.MIGRATION_31_32
import com.owncloud.android.data.migrations.MIGRATION_32_33
import com.owncloud.android.data.migrations.MIGRATION_33_34
import com.owncloud.android.data.migrations.MIGRATION_34_35
import com.owncloud.android.data.migrations.MIGRATION_35_36
import com.owncloud.android.data.migrations.MIGRATION_37_38
import com.owncloud.android.data.migrations.MIGRATION_41_42
import com.owncloud.android.data.migrations.MIGRATION_42_43
import com.owncloud.android.testutil.OC_CAPABILITY
import org.junit.Assert.assertEquals
import org.junit.Test
Expand All @@ -50,7 +61,20 @@ class MigrationToDB30Test : MigrationTest() {
currentVersion = DB_VERSION_30,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo30(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand All @@ -61,7 +85,20 @@ class MigrationToDB30Test : MigrationTest() {
currentVersion = DB_VERSION_30,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo30(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand All @@ -72,7 +109,20 @@ class MigrationToDB30Test : MigrationTest() {
currentVersion = DB_VERSION_30,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo30(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ package com.owncloud.android.data.roommigrations

import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.test.filters.SmallTest
import com.owncloud.android.data.OwncloudDatabase
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.OCSHARES_TABLE_NAME
import com.owncloud.android.data.migrations.MIGRATION_27_28
import com.owncloud.android.data.migrations.MIGRATION_28_29
import com.owncloud.android.data.migrations.MIGRATION_29_30
import com.owncloud.android.data.migrations.MIGRATION_30_31
import com.owncloud.android.data.migrations.MIGRATION_31_32
import com.owncloud.android.data.migrations.MIGRATION_32_33
import com.owncloud.android.data.migrations.MIGRATION_33_34
import com.owncloud.android.data.migrations.MIGRATION_34_35
import com.owncloud.android.data.migrations.MIGRATION_35_36
import com.owncloud.android.data.migrations.MIGRATION_37_38
import com.owncloud.android.data.migrations.MIGRATION_41_42
import com.owncloud.android.data.migrations.MIGRATION_42_43
import com.owncloud.android.testutil.OC_SHARE
import org.junit.Assert.assertEquals
import org.junit.Test
Expand All @@ -41,7 +52,20 @@ class MigrationToDB33Test : MigrationTest() {
currentVersion = DB_VERSION_33,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo33(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ package com.owncloud.android.data.roommigrations

import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.test.filters.SmallTest
import com.owncloud.android.data.OwncloudDatabase
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.FOLDER_BACKUP_TABLE_NAME
import com.owncloud.android.data.migrations.MIGRATION_27_28
import com.owncloud.android.data.migrations.MIGRATION_28_29
import com.owncloud.android.data.migrations.MIGRATION_29_30
import com.owncloud.android.data.migrations.MIGRATION_30_31
import com.owncloud.android.data.migrations.MIGRATION_31_32
import com.owncloud.android.data.migrations.MIGRATION_32_33
import com.owncloud.android.data.migrations.MIGRATION_33_34
import com.owncloud.android.data.migrations.MIGRATION_34_35
import com.owncloud.android.data.migrations.MIGRATION_35_36
import com.owncloud.android.data.migrations.MIGRATION_37_38
import com.owncloud.android.data.migrations.MIGRATION_41_42
import com.owncloud.android.data.migrations.MIGRATION_42_43
import com.owncloud.android.testutil.OC_BACKUP
import org.junit.Assert
import org.junit.Test
Expand All @@ -38,7 +49,20 @@ class MigrationToDB35Test : MigrationTest() {
currentVersion = DB_VERSION_35,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo35(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ package com.owncloud.android.data.roommigrations

import androidx.sqlite.db.SupportSQLiteDatabase
import androidx.test.filters.SmallTest
import com.owncloud.android.data.OwncloudDatabase
import com.owncloud.android.data.ProviderMeta.ProviderTableMeta.CAPABILITIES_TABLE_NAME
import com.owncloud.android.data.migrations.MIGRATION_27_28
import com.owncloud.android.data.migrations.MIGRATION_28_29
import com.owncloud.android.data.migrations.MIGRATION_29_30
import com.owncloud.android.data.migrations.MIGRATION_30_31
import com.owncloud.android.data.migrations.MIGRATION_31_32
import com.owncloud.android.data.migrations.MIGRATION_32_33
import com.owncloud.android.data.migrations.MIGRATION_33_34
import com.owncloud.android.data.migrations.MIGRATION_34_35
import com.owncloud.android.data.migrations.MIGRATION_35_36
import com.owncloud.android.data.migrations.MIGRATION_37_38
import com.owncloud.android.data.migrations.MIGRATION_41_42
import com.owncloud.android.data.migrations.MIGRATION_42_43
import com.owncloud.android.testutil.OC_CAPABILITY
import org.junit.Assert
import org.junit.Test
Expand All @@ -38,7 +49,20 @@ class MigrationToDB36Test : MigrationTest() {
currentVersion = DB_VERSION_36,
insertData = { database -> insertDataToTest(database) },
validateMigration = { database -> validateMigrationTo36(database) },
listOfMigrations = OwncloudDatabase.ALL_MIGRATIONS
listOfMigrations = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,6 @@ abstract class OwncloudDatabase : RoomDatabase() {
@Volatile
private var INSTANCE: OwncloudDatabase? = null

val ALL_MIGRATIONS = arrayOf(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43,
)

fun getDatabase(
context: Context
): OwncloudDatabase =
Expand All @@ -126,7 +111,19 @@ abstract class OwncloudDatabase : RoomDatabase() {
OwncloudDatabase::class.java,
ProviderMeta.NEW_DB_NAME
)
.addMigrations(*ALL_MIGRATIONS)
.addMigrations(
MIGRATION_27_28,
MIGRATION_28_29,
MIGRATION_29_30,
MIGRATION_30_31,
MIGRATION_31_32,
MIGRATION_32_33,
MIGRATION_33_34,
MIGRATION_34_35,
MIGRATION_35_36,
MIGRATION_37_38,
MIGRATION_41_42,
MIGRATION_42_43)
.build()
INSTANCE = instance
instance
Expand Down

0 comments on commit 3493a1d

Please sign in to comment.