Skip to content

Commit c2b3f0e

Browse files
committed
Some more tiny refactoring
1 parent 3111866 commit c2b3f0e

9 files changed

Lines changed: 110 additions & 110 deletions

File tree

owncloudData/src/test/java/com/owncloud/android/data/folderbackup/datasources/implementation/OCLocalFolderBackupDataSourceTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ import org.junit.Test
3838

3939
class OCLocalFolderBackupDataSourceTest {
4040

41-
private lateinit var mOcLocalFolderBackupDataSource: OCLocalFolderBackupDataSource
41+
private lateinit var ocLocalFolderBackupDataSource: OCLocalFolderBackupDataSource
4242
private val folderBackupDao = mockk<FolderBackupDao>(relaxed = true)
4343

4444
@Before
4545
fun setUp() {
46-
mOcLocalFolderBackupDataSource = OCLocalFolderBackupDataSource(folderBackupDao)
46+
ocLocalFolderBackupDataSource = OCLocalFolderBackupDataSource(folderBackupDao)
4747
}
4848

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

54-
val resultCurrent = mOcLocalFolderBackupDataSource.getCameraUploadsConfiguration()
54+
val resultCurrent = ocLocalFolderBackupDataSource.getCameraUploadsConfiguration()
5555

5656
assertEquals(OC_BACKUP_ENTITY.toModel(), resultCurrent?.pictureUploadsConfiguration)
5757
assertEquals(OC_BACKUP_ENTITY.toModel(), resultCurrent?.videoUploadsConfiguration)
@@ -67,7 +67,7 @@ class OCLocalFolderBackupDataSourceTest {
6767
every { folderBackupDao.getFolderBackUpConfigurationByName(FolderBackUpConfiguration.pictureUploadsName) } returns null
6868
every { folderBackupDao.getFolderBackUpConfigurationByName(FolderBackUpConfiguration.videoUploadsName) } returns null
6969

70-
val resultCurrent = mOcLocalFolderBackupDataSource.getCameraUploadsConfiguration()
70+
val resultCurrent = ocLocalFolderBackupDataSource.getCameraUploadsConfiguration()
7171

7272
assertNull(resultCurrent)
7373

@@ -78,12 +78,12 @@ class OCLocalFolderBackupDataSourceTest {
7878
}
7979

8080
@Test
81-
fun `getFolderBackupConfigurationByNameAsFlow returns a flow of CameraUploadsConfiguration when having valid configurations`() = runBlocking {
81+
fun `getFolderBackupConfigurationByNameAsFlow returns a Flow of CameraUploadsConfiguration when having valid configurations`() = runBlocking {
8282
every { folderBackupDao.getFolderBackUpConfigurationByNameAsFlow(FolderBackUpConfiguration.pictureUploadsName) } returns flowOf(
8383
OC_BACKUP_ENTITY
8484
)
8585

86-
val resultCurrent = mOcLocalFolderBackupDataSource.getFolderBackupConfigurationByNameAsFlow(FolderBackUpConfiguration.pictureUploadsName)
86+
val resultCurrent = ocLocalFolderBackupDataSource.getFolderBackupConfigurationByNameAsFlow(FolderBackUpConfiguration.pictureUploadsName)
8787

8888
val result = resultCurrent.first()
8989
assertEquals(OC_BACKUP_ENTITY.toModel(), result)
@@ -94,17 +94,17 @@ class OCLocalFolderBackupDataSourceTest {
9494
}
9595

9696
@Test
97-
fun `saveFolderBackupConfiguration with valid configurations saves the information`() {
98-
mOcLocalFolderBackupDataSource.saveFolderBackupConfiguration(OC_BACKUP)
97+
fun `saveFolderBackupConfiguration saves valid configurations correctly`() {
98+
ocLocalFolderBackupDataSource.saveFolderBackupConfiguration(OC_BACKUP)
9999

100100
verify(exactly = 1) {
101101
folderBackupDao.update(OC_BACKUP_ENTITY)
102102
}
103103
}
104104

105105
@Test
106-
fun `resetFolderBackupConfigurationByName removes current folder backup configuration`() {
107-
mOcLocalFolderBackupDataSource.resetFolderBackupConfigurationByName(FolderBackUpConfiguration.pictureUploadsName)
106+
fun `resetFolderBackupConfigurationByName removes current folder backup configuration correctly`() {
107+
ocLocalFolderBackupDataSource.resetFolderBackupConfigurationByName(FolderBackUpConfiguration.pictureUploadsName)
108108

109109
verify(exactly = 1) {
110110
folderBackupDao.delete(FolderBackUpConfiguration.pictureUploadsName)

owncloudData/src/test/java/com/owncloud/android/data/oauth/datasources/OCRemoteOAuthDataSourceTest.kt renamed to owncloudData/src/test/java/com/owncloud/android/data/oauth/datasources/implementation/OCRemoteOAuthDataSourceTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20-
package com.owncloud.android.data.oauth.datasources
20+
package com.owncloud.android.data.oauth.datasources.implementation
2121

2222
import com.owncloud.android.data.ClientManager
2323
import com.owncloud.android.data.oauth.OC_REMOTE_CLIENT_REGISTRATION_RESPONSE
2424
import com.owncloud.android.data.oauth.OC_REMOTE_OIDC_DISCOVERY_RESPONSE
2525
import com.owncloud.android.data.oauth.OC_REMOTE_TOKEN_RESPONSE
26-
import com.owncloud.android.data.oauth.datasources.implementation.OCRemoteOAuthDataSource
2726
import com.owncloud.android.lib.common.OwnCloudClient
2827
import com.owncloud.android.lib.common.operations.RemoteOperationResult
2928
import com.owncloud.android.lib.resources.oauth.responses.ClientRegistrationResponse
@@ -46,7 +45,7 @@ import org.junit.Before
4645
import org.junit.Test
4746

4847
class OCRemoteOAuthDataSourceTest {
49-
private lateinit var remoteOAuthDataSource: RemoteOAuthDataSource
48+
private lateinit var remoteOAuthDataSource: OCRemoteOAuthDataSource
5049

5150
private val clientManager: ClientManager = mockk(relaxed = true)
5251
private val ocClientMocked: OwnCloudClient = mockk()

owncloudData/src/test/java/com/owncloud/android/data/sharing/shares/datasources/implementation/OCLocalShareDataSourceTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class OCLocalShareDataSourceTest {
7878
private val privateShareTypes = listOf(ShareType.USER, ShareType.GROUP, ShareType.FEDERATED)
7979

8080
@Test
81-
fun `getSharesAsLiveData returns a list of LiveData OCShare when read local private shares`() {
81+
fun `getSharesAsLiveData returns a LiveData of a list of OCShare when read local private shares`() {
8282
val privateSharesAsLiveData: MutableLiveData<List<OCShareEntity>> = MutableLiveData()
8383
privateSharesAsLiveData.value = privateShares
8484

@@ -198,7 +198,7 @@ class OCLocalShareDataSourceTest {
198198
)
199199

200200
@Test
201-
fun `getSharesAsLiveData read local public shares returns a list of LiveData OCShare`() {
201+
fun `getSharesAsLiveData returns a LiveData of a list of OCShare when read local public shares`() {
202202
val publicSharesAsLiveData: MutableLiveData<List<OCShareEntity>> = MutableLiveData()
203203
publicSharesAsLiveData.value = publicShares
204204

@@ -291,7 +291,7 @@ class OCLocalShareDataSourceTest {
291291
**************************************************************************************************************/
292292

293293
@Test
294-
fun `replaceShares updates a list of shares correctly`() {
294+
fun `replaceShares updates a list of OCShare correctly`() {
295295
val expectedValues = listOf<Long>(1, 2)
296296
every { ocSharesDao.replaceShares(publicShares) } returns expectedValues
297297

owncloudData/src/test/java/com/owncloud/android/data/sharing/shares/datasources/implementation/OCRemoteShareDataSourceTest.kt

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import com.owncloud.android.utils.createRemoteOperationResultMock
3636
import io.mockk.every
3737
import io.mockk.mockk
3838
import io.mockk.verify
39-
import org.hamcrest.CoreMatchers.notNullValue
40-
import org.hamcrest.MatcherAssert.assertThat
4139
import org.junit.Assert.assertEquals
4240
import org.junit.Before
4341
import org.junit.Test
@@ -91,7 +89,6 @@ class OCRemoteShareDataSourceTest {
9189
)
9290
} returns createRemoteShareOperationResult
9391

94-
// Insert share on remote datasource
9592
val privateShareAdded = ocRemoteShareDataSource.insert(
9693
remoteFilePath = "Photos/",
9794
shareType = ShareType.USER,
@@ -100,8 +97,6 @@ class OCRemoteShareDataSourceTest {
10097
accountName = OC_ACCOUNT_NAME
10198
)
10299

103-
assertThat(privateShareAdded, notNullValue())
104-
105100
assertEquals("Photos/", privateShareAdded.path)
106101
assertEquals(true, privateShareAdded.isFolder)
107102
assertEquals("user", privateShareAdded.shareWith)
@@ -152,15 +147,12 @@ class OCRemoteShareDataSourceTest {
152147
)
153148
} returns updateRemoteShareOperationResult
154149

155-
// Update share on remote datasource
156150
val privateShareUpdated = ocRemoteShareDataSource.updateShare(
157151
remoteId = "3",
158152
permissions = 17,
159153
accountName = OC_ACCOUNT_NAME
160154
)
161155

162-
assertThat(privateShareUpdated, notNullValue())
163-
164156
assertEquals("Images/image_1.mp4", privateShareUpdated.path)
165157
assertEquals("user", privateShareUpdated.shareWith)
166158
assertEquals("User", privateShareUpdated.sharedWithDisplayName)
@@ -213,7 +205,6 @@ class OCRemoteShareDataSourceTest {
213205
)
214206
} returns createRemoteShareOperationResult
215207

216-
// Insert share on remote datasource
217208
val publicShareAdded = ocRemoteShareDataSource.insert(
218209
"Photos/img1.png",
219210
ShareType.PUBLIC_LINK,
@@ -222,8 +213,6 @@ class OCRemoteShareDataSourceTest {
222213
accountName = OC_ACCOUNT_NAME
223214
)
224215

225-
assertThat(publicShareAdded, notNullValue())
226-
227216
assertEquals("", publicShareAdded.shareWith)
228217
assertEquals(1, publicShareAdded.permissions)
229218
assertEquals("img1 link", publicShareAdded.name)
@@ -275,15 +264,12 @@ class OCRemoteShareDataSourceTest {
275264
)
276265
} returns updateRemoteShareOperationResult
277266

278-
// Update share on remote datasource
279267
val publicShareUpdated = ocRemoteShareDataSource.updateShare(
280268
remoteId = "3",
281269
permissions = 17,
282270
accountName = OC_ACCOUNT_NAME
283271
)
284272

285-
assertThat(publicShareUpdated, notNullValue())
286-
287273
assertEquals("video1 link updated", publicShareUpdated.name)
288274
assertEquals("Videos/video1.mp4", publicShareUpdated.path)
289275
assertEquals(false, publicShareUpdated.isFolder)
@@ -353,7 +339,6 @@ class OCRemoteShareDataSourceTest {
353339
ocShareService.getShares(any(), any(), any())
354340
} returns getRemoteSharesOperationResult
355341

356-
// Get shares from remote datasource
357342
val shares = ocRemoteShareDataSource.getShares(
358343
remoteFilePath = "/Documents/doc",
359344
reshares = true,
@@ -402,16 +387,16 @@ class OCRemoteShareDataSourceTest {
402387
}
403388

404389
@Test(expected = ShareNotFoundException::class)
405-
fun `insert share file not found`() {
406-
createShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)
390+
fun `insert throws a ShareNotFoundException when share is not found`() {
391+
insertShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)
407392
}
408393

409394
@Test(expected = ShareForbiddenException::class)
410-
fun `insert share forbidden`() {
411-
createShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_FORBIDDEN)
395+
fun `insert throws a ShareForbiddenException when share is forbidden`() {
396+
insertShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_FORBIDDEN)
412397
}
413398

414-
private fun createShareOperationWithError(resultCode: RemoteOperationResult.ResultCode? = null) {
399+
private fun insertShareOperationWithError(resultCode: RemoteOperationResult.ResultCode? = null) {
415400
val createRemoteSharesOperationResult = createRemoteOperationResultMock(
416401
ShareResponse(arrayListOf()),
417402
false,
@@ -433,12 +418,12 @@ class OCRemoteShareDataSourceTest {
433418
}
434419

435420
@Test(expected = ShareNotFoundException::class)
436-
fun `update share file not found`() {
421+
fun `updateShare throws a ShareNotFoundException when share is not found`() {
437422
updateShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)
438423
}
439424

440425
@Test(expected = ShareForbiddenException::class)
441-
fun `update share forbidden`() {
426+
fun `updateShare throws a ShareForbiddenException when share is forbidden`() {
442427
updateShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_FORBIDDEN)
443428
}
444429

@@ -480,12 +465,12 @@ class OCRemoteShareDataSourceTest {
480465
}
481466

482467
@Test(expected = ShareNotFoundException::class)
483-
fun `remove share file not found`() {
468+
fun `deleteShare throws ShareNotFoundException when share is not found`() {
484469
deleteShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)
485470
}
486471

487472
@Test(expected = ShareForbiddenException::class)
488-
fun `remove share forbidden`() {
473+
fun `deleteShare throws ShareForbiddenException when share is forbidden`() {
489474
deleteShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_FORBIDDEN)
490475
}
491476

owncloudData/src/test/java/com/owncloud/android/data/spaces/datasources/implementation/OCLocalSpacesDataSourceTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class OCLocalSpacesDataSourceTest {
5656
}
5757

5858
@Test
59-
fun `saveSpacesForAccount inserts spaces and special spaces`() {
59+
fun `saveSpacesForAccount inserts spaces and special spaces correctly`() {
6060
val spaceEntities = mutableListOf<SpacesEntity>()
6161
val spaceSpecialEntities = mutableListOf<SpaceSpecialEntity>()
6262

@@ -109,7 +109,7 @@ class OCLocalSpacesDataSourceTest {
109109
}
110110

111111
@Test
112-
fun `getSpacesFromEveryAccountAsStream returns a flow of OCSpace`() = runBlocking {
112+
fun `getSpacesFromEveryAccountAsStream returns a Flow with a list of OCSpace`() = runBlocking {
113113

114114
every {
115115
spacesDao.getSpacesByDriveTypeFromEveryAccountAsStream(
@@ -135,7 +135,7 @@ class OCLocalSpacesDataSourceTest {
135135
}
136136

137137
@Test
138-
fun `getSpacesByDriveTypeWithSpecialsForAccountAsFlow returns a flow of OCSpace list`() = runBlocking {
138+
fun `getSpacesByDriveTypeWithSpecialsForAccountAsFlow returns a Flow with a list of OCSpace`() = runBlocking {
139139

140140
every {
141141
spacesDao.getSpacesByDriveTypeWithSpecialsForAccountAsFlow(
@@ -217,7 +217,7 @@ class OCLocalSpacesDataSourceTest {
217217
}
218218

219219
@Test
220-
fun `getWebDavUrlForSpace returns a string of webDavUrl`() {
220+
fun `getWebDavUrlForSpace returns a String of webDavUrl`() {
221221

222222
every {
223223
spacesDao.getWebDavUrlForSpace(OC_SPACE_PERSONAL.id, OC_ACCOUNT_NAME)
@@ -235,7 +235,7 @@ class OCLocalSpacesDataSourceTest {
235235
}
236236

237237
@Test
238-
fun `deleteSpacesForAccount delete the space by account`() {
238+
fun `deleteSpacesForAccount removes the spaces for an account correctly`() {
239239

240240
every {
241241
spacesDao.deleteSpacesForAccount(OC_ACCOUNT_NAME)

0 commit comments

Comments
 (0)