Skip to content

Commit

Permalink
changed name OCLocalFolderBackupDataSource
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitorbp committed Oct 16, 2023
1 parent aa47e83 commit 26cd098
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import com.owncloud.android.data.capabilities.datasources.LocalCapabilitiesDataS
import com.owncloud.android.data.capabilities.datasources.implementation.OCLocalCapabilitiesDataSource
import com.owncloud.android.data.files.datasources.LocalFileDataSource
import com.owncloud.android.data.files.datasources.implementation.OCLocalFileDataSource
import com.owncloud.android.data.folderbackup.datasources.FolderBackupLocalDataSource
import com.owncloud.android.data.folderbackup.datasources.implementation.OCFolderBackupLocalDataSource
import com.owncloud.android.data.folderbackup.datasources.LocalFolderBackupDataSource
import com.owncloud.android.data.folderbackup.datasources.implementation.OCLocalFolderBackupDataSource
import com.owncloud.android.data.providers.SharedPreferencesProvider
import com.owncloud.android.data.providers.implementation.OCSharedPreferencesProvider
import com.owncloud.android.data.sharing.shares.datasources.LocalShareDataSource
Expand Down Expand Up @@ -72,7 +72,7 @@ val localDataSourceModule = module {
factory<LocalFileDataSource> { OCLocalFileDataSource(get()) }
factory<LocalShareDataSource> { OCLocalShareDataSource(get()) }
factory<LocalUserDataSource> { OCLocalUserDataSource(get()) }
factory<FolderBackupLocalDataSource> { OCFolderBackupLocalDataSource(get()) }
factory<LocalFolderBackupDataSource> { OCLocalFolderBackupDataSource(get()) }
factory<LocalTransferDataSource> { OCLocalTransferDataSource(get()) }
factory<LocalSpacesDataSource> { OCLocalSpacesDataSource(get()) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ import com.owncloud.android.data.capabilities.datasources.implementation.OCLocal
import com.owncloud.android.data.capabilities.datasources.implementation.OCLocalCapabilitiesDataSource.Companion.toModel
import com.owncloud.android.data.capabilities.db.OCCapabilityEntity
import com.owncloud.android.data.files.db.OCFileEntity
import com.owncloud.android.data.folderbackup.datasources.FolderBackupLocalDataSource
import com.owncloud.android.data.folderbackup.datasources.implementation.OCFolderBackupLocalDataSource
import com.owncloud.android.data.folderbackup.datasources.LocalFolderBackupDataSource
import com.owncloud.android.data.folderbackup.datasources.implementation.OCLocalFolderBackupDataSource
import com.owncloud.android.data.migrations.CameraUploadsMigrationToRoom
import com.owncloud.android.data.providers.SharedPreferencesProvider
import com.owncloud.android.data.providers.implementation.OCSharedPreferencesProvider
Expand Down Expand Up @@ -973,8 +973,8 @@ class FileContentProvider(val executors: Executors = Executors()) : ContentProvi
val pictureUploadsConfiguration = migrationToRoom.getPictureUploadsConfigurationPreferences(pictureUploadsTimestamp)
val videoUploadsConfiguration = migrationToRoom.getVideoUploadsConfigurationPreferences(videoUploadsTimestamp)

val backupLocalDataSource: FolderBackupLocalDataSource =
OCFolderBackupLocalDataSource(OwncloudDatabase.getDatabase(context!!).folderBackUpDao())
val backupLocalDataSource: LocalFolderBackupDataSource =
OCLocalFolderBackupDataSource(OwncloudDatabase.getDatabase(context!!).folderBackUpDao())
// Insert camera uploads configuration in new database
executors.diskIO().execute {
pictureUploadsConfiguration?.let { backupLocalDataSource.saveFolderBackupConfiguration(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@
*/
package com.owncloud.android.data.folderbackup

import com.owncloud.android.data.folderbackup.datasources.FolderBackupLocalDataSource
import com.owncloud.android.data.folderbackup.datasources.LocalFolderBackupDataSource
import com.owncloud.android.domain.camerauploads.FolderBackupRepository
import com.owncloud.android.domain.camerauploads.model.CameraUploadsConfiguration
import com.owncloud.android.domain.camerauploads.model.FolderBackUpConfiguration
import kotlinx.coroutines.flow.Flow

class OCFolderBackupRepository(
private val folderBackupLocalDataSource: FolderBackupLocalDataSource
private val localFolderBackupDataSource: LocalFolderBackupDataSource
) : FolderBackupRepository {

override fun getCameraUploadsConfiguration(): CameraUploadsConfiguration? =
folderBackupLocalDataSource.getCameraUploadsConfiguration()
localFolderBackupDataSource.getCameraUploadsConfiguration()

override fun getFolderBackupConfigurationByNameAsFlow(name: String): Flow<FolderBackUpConfiguration?> =
folderBackupLocalDataSource.getFolderBackupConfigurationByNameAsFlow(name)
localFolderBackupDataSource.getFolderBackupConfigurationByNameAsFlow(name)

override fun saveFolderBackupConfiguration(folderBackUpConfiguration: FolderBackUpConfiguration) {
folderBackupLocalDataSource.saveFolderBackupConfiguration(folderBackUpConfiguration)
localFolderBackupDataSource.saveFolderBackupConfiguration(folderBackUpConfiguration)
}

override fun resetFolderBackupConfigurationByName(name: String) =
folderBackupLocalDataSource.resetFolderBackupConfigurationByName(name)
localFolderBackupDataSource.resetFolderBackupConfigurationByName(name)

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import com.owncloud.android.domain.camerauploads.model.CameraUploadsConfiguratio
import com.owncloud.android.domain.camerauploads.model.FolderBackUpConfiguration
import kotlinx.coroutines.flow.Flow

interface FolderBackupLocalDataSource {
interface LocalFolderBackupDataSource {
fun getCameraUploadsConfiguration(): CameraUploadsConfiguration?

fun getFolderBackupConfigurationByNameAsFlow(name: String): Flow<FolderBackUpConfiguration?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.owncloud.android.data.folderbackup.datasources.implementation

import androidx.annotation.VisibleForTesting
import com.owncloud.android.data.folderbackup.datasources.FolderBackupLocalDataSource
import com.owncloud.android.data.folderbackup.datasources.LocalFolderBackupDataSource
import com.owncloud.android.data.folderbackup.db.FolderBackUpEntity
import com.owncloud.android.data.folderbackup.db.FolderBackupDao
import com.owncloud.android.domain.camerauploads.model.CameraUploadsConfiguration
Expand All @@ -30,9 +30,9 @@ import com.owncloud.android.domain.camerauploads.model.UploadBehavior
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map

class OCFolderBackupLocalDataSource(
class OCLocalFolderBackupDataSource(
private val folderBackupDao: FolderBackupDao,
) : FolderBackupLocalDataSource {
) : LocalFolderBackupDataSource {

override fun getCameraUploadsConfiguration(): CameraUploadsConfiguration? {
val pictureUploadsConfiguration = folderBackupDao.getFolderBackUpConfigurationByName(pictureUploadsName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package com.owncloud.android.data.folderbackup.datasources.implementation

import com.owncloud.android.data.folderbackup.datasources.implementation.OCFolderBackupLocalDataSource.Companion.toModel
import com.owncloud.android.data.folderbackup.datasources.implementation.OCLocalFolderBackupDataSource.Companion.toModel
import com.owncloud.android.data.folderbackup.db.FolderBackupDao
import com.owncloud.android.domain.camerauploads.model.FolderBackUpConfiguration
import com.owncloud.android.testutil.OC_BACKUP
Expand All @@ -36,22 +36,22 @@ import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test

class OCFolderBackupLocalDataSourceTest {
class OCLocalFolderBackupDataSourceTest {

private lateinit var ocFolderBackupLocalDataSource: OCFolderBackupLocalDataSource
private lateinit var mOcLocalFolderBackupDataSource: OCLocalFolderBackupDataSource
private val folderBackupDao = mockk<FolderBackupDao>(relaxed = true)

@Before
fun setUp() {
ocFolderBackupLocalDataSource = OCFolderBackupLocalDataSource(folderBackupDao)
mOcLocalFolderBackupDataSource = OCLocalFolderBackupDataSource(folderBackupDao)
}

@Test
fun `getCameraUploadsConfiguration returns a CameraUploadsConfiguration when having valid configurations`() {
every { folderBackupDao.getFolderBackUpConfigurationByName(FolderBackUpConfiguration.pictureUploadsName) } returns OC_BACKUP_ENTITY
every { folderBackupDao.getFolderBackUpConfigurationByName(FolderBackUpConfiguration.videoUploadsName) } returns OC_BACKUP_ENTITY

val resultCurrent = ocFolderBackupLocalDataSource.getCameraUploadsConfiguration()
val resultCurrent = mOcLocalFolderBackupDataSource.getCameraUploadsConfiguration()

assertEquals(OC_BACKUP_ENTITY.toModel(), resultCurrent?.pictureUploadsConfiguration)
assertEquals(OC_BACKUP_ENTITY.toModel(), resultCurrent?.videoUploadsConfiguration)
Expand All @@ -67,7 +67,7 @@ class OCFolderBackupLocalDataSourceTest {
every { folderBackupDao.getFolderBackUpConfigurationByName(FolderBackUpConfiguration.pictureUploadsName) } returns null
every { folderBackupDao.getFolderBackUpConfigurationByName(FolderBackUpConfiguration.videoUploadsName) } returns null

val resultCurrent = ocFolderBackupLocalDataSource.getCameraUploadsConfiguration()
val resultCurrent = mOcLocalFolderBackupDataSource.getCameraUploadsConfiguration()

assertNull(resultCurrent)

Expand All @@ -83,7 +83,7 @@ class OCFolderBackupLocalDataSourceTest {
OC_BACKUP_ENTITY
)

val resultCurrent = ocFolderBackupLocalDataSource.getFolderBackupConfigurationByNameAsFlow(FolderBackUpConfiguration.pictureUploadsName)
val resultCurrent = mOcLocalFolderBackupDataSource.getFolderBackupConfigurationByNameAsFlow(FolderBackUpConfiguration.pictureUploadsName)

val result = resultCurrent.first()
assertEquals(OC_BACKUP_ENTITY.toModel(), result)
Expand All @@ -95,7 +95,7 @@ class OCFolderBackupLocalDataSourceTest {

@Test
fun `saveFolderBackupConfiguration with valid configurations saves the information`() {
ocFolderBackupLocalDataSource.saveFolderBackupConfiguration(OC_BACKUP)
mOcLocalFolderBackupDataSource.saveFolderBackupConfiguration(OC_BACKUP)

verify(exactly = 1) {
folderBackupDao.update(OC_BACKUP_ENTITY)
Expand All @@ -104,7 +104,7 @@ class OCFolderBackupLocalDataSourceTest {

@Test
fun `resetFolderBackupConfigurationByName removes current folder backup configuration`() {
ocFolderBackupLocalDataSource.resetFolderBackupConfigurationByName(FolderBackUpConfiguration.pictureUploadsName)
mOcLocalFolderBackupDataSource.resetFolderBackupConfigurationByName(FolderBackUpConfiguration.pictureUploadsName)

verify(exactly = 1) {
folderBackupDao.delete(FolderBackUpConfiguration.pictureUploadsName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class OCLocalShareDataSourceTest {
**************************************************************************************************************/

@Test
fun `replaceShares renewal shares related to a list of shares`() {
fun `replaceShares update a list of shares correctly`() {
val expectedValues = listOf<Long>(1, 2)
every { ocSharesDao.replaceShares(publicShares) } returns expectedValues

Expand Down

0 comments on commit 26cd098

Please sign in to comment.