-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd6f61b
commit fd98291
Showing
24 changed files
with
434 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ava/com/owncloud/android/data/authentication/repository/OCAuthenticationRepositoryTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* ownCloud Android client application | ||
* | ||
* @author Abel García de Prada | ||
* Copyright (C) 2020 ownCloud GmbH. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.owncloud.android.data.authentication.repository | ||
|
||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule | ||
import com.owncloud.android.data.authentication.datasources.RemoteAuthenticationDataSource | ||
import com.owncloud.android.domain.exceptions.NoConnectionWithServerException | ||
import com.owncloud.android.testutil.OC_ServerInfo | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class OCAuthenticationRepositoryTest { | ||
@Rule | ||
@JvmField | ||
val instantExecutorRule = InstantTaskExecutorRule() | ||
|
||
private val remoteAuthenticationDataSource = mockk<RemoteAuthenticationDataSource>(relaxed = true) | ||
private val ocAuthenticationRepository: OCAuthenticationRepository = | ||
OCAuthenticationRepository(remoteAuthenticationDataSource) | ||
|
||
@Test | ||
fun loginOk() { | ||
every { remoteAuthenticationDataSource.login(any(), any(), any()) } returns Unit | ||
|
||
ocAuthenticationRepository.login(OC_ServerInfo.baseUrl, "username", "password") | ||
|
||
verify(exactly = 1) { | ||
remoteAuthenticationDataSource.login(OC_ServerInfo.baseUrl, "username", "password") | ||
} | ||
} | ||
|
||
@Test(expected = NoConnectionWithServerException::class) | ||
fun loginException() { | ||
every { | ||
remoteAuthenticationDataSource.login(any(), any(), any()) | ||
} throws NoConnectionWithServerException() | ||
|
||
ocAuthenticationRepository.login(OC_ServerInfo.baseUrl, "test", "test") | ||
|
||
verify(exactly = 1) { | ||
remoteAuthenticationDataSource.login(any(), any(), any()) | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...test/java/com/owncloud/android/data/server/datasources/OCRemoteAnonymousDatasourceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.owncloud.android.data.server.datasources | ||
|
||
import com.owncloud.android.data.server.datasources.implementation.OCRemoteAnonymousDataSource | ||
import com.owncloud.android.data.server.network.OCAnonymousServerService | ||
import io.mockk.mockk | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class OCRemoteAnonymousDatasourceTest { | ||
private lateinit var ocRemoteAnonymousDatasource: OCRemoteAnonymousDataSource | ||
|
||
private val ocAnonymousService: OCAnonymousServerService = mockk() | ||
|
||
@Before | ||
fun init() { | ||
ocRemoteAnonymousDatasource = OCRemoteAnonymousDataSource(ocAnonymousService) | ||
} | ||
|
||
//TODO: Test getAuthenticationMethod and getRemoteStatus | ||
} |
71 changes: 71 additions & 0 deletions
71
...rc/test/java/com/owncloud/android/data/server/datasources/OCRemoteServerDataSourceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* ownCloud Android client application | ||
* | ||
* @author Abel García de Prada | ||
* Copyright (C) 2020 ownCloud GmbH. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.owncloud.android.data.server.datasources | ||
|
||
import com.owncloud.android.data.server.datasources.implementation.OCRemoteServerDataSource | ||
import com.owncloud.android.data.server.network.OCServerService | ||
import com.owncloud.android.lib.common.operations.RemoteOperationResult | ||
import com.owncloud.android.testutil.OC_ServerInfo | ||
import com.owncloud.android.utils.createRemoteOperationResultMock | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class OCRemoteServerDataSourceTest { | ||
private lateinit var ocRemoteServerDataSource: OCRemoteServerDataSource | ||
|
||
private val ocServerService: OCServerService = mockk() | ||
|
||
@Before | ||
fun init() { | ||
ocRemoteServerDataSource = OCRemoteServerDataSource(ocServerService) | ||
} | ||
|
||
@Test | ||
fun checkPathExistenceTrue() { | ||
val checkPathExistenceRemoteResult: RemoteOperationResult<Boolean> = createRemoteOperationResultMock(data = true, isSuccess = true) | ||
|
||
every { | ||
ocServerService.checkPathExistence(OC_ServerInfo.baseUrl, true) | ||
} returns checkPathExistenceRemoteResult | ||
|
||
val checkPathExistence = ocRemoteServerDataSource.checkPathExistence(OC_ServerInfo.baseUrl, true) | ||
|
||
assertNotNull(checkPathExistence) | ||
assertEquals(checkPathExistenceRemoteResult.data, checkPathExistence) | ||
} | ||
|
||
@Test | ||
fun checkPathExistenceFalse() { | ||
val checkPathExistenceRemoteResult: RemoteOperationResult<Boolean> = createRemoteOperationResultMock(data = false, isSuccess = true) | ||
|
||
every { | ||
ocServerService.checkPathExistence(OC_ServerInfo.baseUrl, true) | ||
} returns checkPathExistenceRemoteResult | ||
|
||
val checkPathExistence = ocRemoteServerDataSource.checkPathExistence(OC_ServerInfo.baseUrl, true) | ||
|
||
assertNotNull(checkPathExistence) | ||
assertEquals(checkPathExistenceRemoteResult.data, checkPathExistence) | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...dData/src/test/java/com/owncloud/android/data/server/repository/OCServerRepositoryTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* ownCloud Android client application | ||
* | ||
* @author Abel García de Prada | ||
* Copyright (C) 2020 ownCloud GmbH. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.owncloud.android.data.server.repository | ||
|
||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule | ||
import com.owncloud.android.data.server.datasources.RemoteServerDataSource | ||
import com.owncloud.android.domain.exceptions.NoConnectionWithServerException | ||
import com.owncloud.android.testutil.OC_ServerInfo | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class OCServerRepositoryTest { | ||
@Rule | ||
@JvmField | ||
val instantExecutorRule = InstantTaskExecutorRule() | ||
|
||
private val remoteServerDataSource = mockk<RemoteServerDataSource>(relaxed = true) | ||
private val ocServerRepository: OCServerRepository = OCServerRepository(remoteServerDataSource) | ||
|
||
@Test | ||
fun checkPathExistenceExists() { | ||
every { remoteServerDataSource.checkPathExistence(OC_ServerInfo.baseUrl, false) } returns true | ||
|
||
ocServerRepository.checkPathExistence(OC_ServerInfo.baseUrl, false) | ||
|
||
verify(exactly = 1) { | ||
remoteServerDataSource.checkPathExistence(OC_ServerInfo.baseUrl, false) | ||
} | ||
} | ||
|
||
@Test(expected = NoConnectionWithServerException::class) | ||
fun checkPathExistenceExistsNoConnection() { | ||
every { remoteServerDataSource.checkPathExistence(OC_ServerInfo.baseUrl, false) } throws NoConnectionWithServerException() | ||
|
||
ocServerRepository.checkPathExistence(OC_ServerInfo.baseUrl, false) | ||
|
||
verify(exactly = 1) { | ||
remoteServerDataSource.checkPathExistence(OC_ServerInfo.baseUrl, false) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.