-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from re-kast/feature/issue_27
🧪 Add tests on teh default repository
- Loading branch information
Showing
7 changed files
with
152 additions
and
21 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
94 changes: 94 additions & 0 deletions
94
android/momo-api-sdk/src/test/java/io/rekast/sdk/repository/DefaultRepositoryTest.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,94 @@ | ||
package io.rekast.sdk.repository | ||
|
||
import io.rekast.sdk.model.ProviderCallBackHost | ||
import io.rekast.sdk.model.authentication.ApiUser | ||
import io.rekast.sdk.model.authentication.credentials.AccessTokenCredentials | ||
import io.rekast.sdk.model.authentication.credentials.BasicAuthCredentials | ||
import io.rekast.sdk.network.service.products.CollectionService | ||
import io.rekast.sdk.network.service.products.CommonService | ||
import io.rekast.sdk.network.service.products.DisbursementsService | ||
import io.rekast.sdk.repository.data.NetworkResult | ||
import kotlinx.coroutines.runBlocking | ||
import org.junit.Before | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.mockito.ArgumentMatchers.any | ||
import org.mockito.Mockito.mock | ||
import org.mockito.kotlin.whenever | ||
|
||
class DefaultRepositoryTest { | ||
|
||
private lateinit var defaultSource: DefaultSource | ||
private lateinit var commonService: CommonService | ||
private lateinit var disbursementsService: DisbursementsService | ||
private lateinit var collectionService: CollectionService | ||
private lateinit var repository: DefaultRepository | ||
|
||
@Before | ||
fun setUp() { | ||
defaultSource = mock() | ||
commonService = mock() | ||
disbursementsService = mock() | ||
collectionService = mock() | ||
repository = DefaultRepository( | ||
defaultSource, | ||
commonService, | ||
disbursementsService, | ||
collectionService, | ||
BasicAuthCredentials("",""), | ||
AccessTokenCredentials("") | ||
) | ||
} | ||
|
||
@Test | ||
@Ignore | ||
fun `test createApiUser success`() = runBlocking { | ||
val providerCallBackHost = ProviderCallBackHost("http://callback.host") | ||
val apiVersion = "v1" | ||
val uuid = "unique-uuid" | ||
val productSubscriptionKey = "subscription-key" | ||
|
||
//whenever(defaultSource.createApiUser(any(), any(), any(), any())).thenReturn(ApiUser()) | ||
|
||
val result = repository.createApiUser(providerCallBackHost, apiVersion, uuid, productSubscriptionKey) | ||
|
||
result.collect { networkResult -> | ||
assert(networkResult is NetworkResult.Success) | ||
} | ||
} | ||
|
||
@Test | ||
@Ignore | ||
fun `test checkApiUser success`() = runBlocking { | ||
val apiVersion = "v1" | ||
val productSubscriptionKey = "subscription-key" | ||
|
||
//whenever(defaultSource.getApiUser( any(), any(), any())).thenReturn(ApiUser()) | ||
|
||
val result = repository.checkApiUser(apiVersion, productSubscriptionKey) | ||
|
||
result.collect { networkResult -> | ||
assert(networkResult is NetworkResult.Success) | ||
} | ||
} | ||
|
||
@Test | ||
fun `test setUpBasicAuth updates credentials`() { | ||
val basicAuthCredentials = BasicAuthCredentials("userId", "apiKey") | ||
|
||
repository.setUpBasicAuth(basicAuthCredentials) | ||
|
||
assert(repository.getBasicAuth().apiUserId == "userId") | ||
assert(repository.getBasicAuth().apiKey == "apiKey") | ||
} | ||
|
||
@Test | ||
fun `test setUpAccessTokenAuth updates credentials`() { | ||
val accessTokenCredentials = AccessTokenCredentials("accessToken") | ||
|
||
repository.setUpAccessTokenAuth(accessTokenCredentials) | ||
|
||
assert(repository.getAccessTokenAuth().accessToken == "accessToken") | ||
} | ||
|
||
} |
18 changes: 0 additions & 18 deletions
18
android/momo-api-sdk/src/test/java/io/rekast/sdk/repository/MomoAPIRepositoryTest.kt
This file was deleted.
Oops, something went wrong.
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