Updated on 2026-08-14
This commit is contained in:
parent
b861d63402
commit
652009a7bf
29 changed files with 271 additions and 256 deletions
|
|
@ -2,9 +2,9 @@ package com.tangem.data.account.fetcher
|
|||
|
||||
import arrow.core.left
|
||||
import arrow.core.right
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.account.fetcher.MultiAccountListFetcher
|
||||
import com.tangem.domain.account.fetcher.SingleAccountListFetcher
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.test.core.assertEitherLeft
|
||||
|
|
@ -19,9 +19,12 @@ import org.junit.jupiter.api.TestInstance
|
|||
class DefaultMultiAccountListFetcherTest {
|
||||
|
||||
private val singleAccountListFetcher: SingleAccountListFetcher = mockk()
|
||||
private val userWalletsStore: UserWalletsStore = mockk(relaxUnitFun = true)
|
||||
private val userWalletsListRepository: UserWalletsListRepository = mockk(relaxUnitFun = true)
|
||||
|
||||
private val fetcher = DefaultMultiAccountListFetcher(singleAccountListFetcher, userWalletsStore)
|
||||
private val fetcher = DefaultMultiAccountListFetcher(
|
||||
singleAccountListFetcher = singleAccountListFetcher,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
)
|
||||
|
||||
private val userWalletId1 = UserWalletId("011")
|
||||
private val userWalletId2 = UserWalletId("012")
|
||||
|
|
@ -35,7 +38,7 @@ class DefaultMultiAccountListFetcherTest {
|
|||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
clearMocks(singleAccountListFetcher, userWalletsStore)
|
||||
clearMocks(singleAccountListFetcher, userWalletsListRepository)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -98,7 +101,7 @@ class DefaultMultiAccountListFetcherTest {
|
|||
// Arrange
|
||||
val params = MultiAccountListFetcher.Params.All
|
||||
|
||||
every { userWalletsStore.userWalletsSync } returns listOf(userWallets.first())
|
||||
every { userWalletsListRepository.userWallets.value } returns listOf(userWallets.first())
|
||||
|
||||
coEvery {
|
||||
singleAccountListFetcher(params = SingleAccountListFetcher.Params(userWalletId1))
|
||||
|
|
@ -111,7 +114,7 @@ class DefaultMultiAccountListFetcherTest {
|
|||
assertEitherRight(actual)
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWalletsSync
|
||||
userWalletsListRepository.userWallets.value
|
||||
singleAccountListFetcher(params = SingleAccountListFetcher.Params(userWalletId1))
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +124,7 @@ class DefaultMultiAccountListFetcherTest {
|
|||
// Arrange
|
||||
val params = MultiAccountListFetcher.Params.All
|
||||
|
||||
every { userWalletsStore.userWalletsSync } returns userWallets
|
||||
every { userWalletsListRepository.userWallets.value } returns userWallets
|
||||
|
||||
val exception = Exception("Fetch failed")
|
||||
coEvery {
|
||||
|
|
@ -145,7 +148,7 @@ class DefaultMultiAccountListFetcherTest {
|
|||
assertEitherLeft(actual, expected)
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWalletsSync
|
||||
userWalletsListRepository.userWallets.value
|
||||
singleAccountListFetcher(params = SingleAccountListFetcher.Params(userWalletId1))
|
||||
singleAccountListFetcher(params = SingleAccountListFetcher.Params(userWalletId2))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.data.account.producer
|
||||
|
||||
import com.google.common.truth.Truth
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.account.models.AccountList
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.core.flow.FlowProducerTools
|
||||
import com.tangem.domain.models.TokensSortType
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
|
|
@ -27,15 +27,15 @@ import org.junit.jupiter.api.TestInstance
|
|||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class DefaultMultiAccountListProducerTest {
|
||||
|
||||
private val userWalletsStore: UserWalletsStore = mockk()
|
||||
private val userWalletsListRepository: UserWalletsListRepository = mockk()
|
||||
private val walletAccountListFlowFactory: WalletAccountListFlowFactory = mockk()
|
||||
private val flowProducerTools: FlowProducerTools = mockk()
|
||||
|
||||
private val producer = DefaultMultiAccountListProducer(
|
||||
params = Unit,
|
||||
userWalletsStore = userWalletsStore,
|
||||
walletAccountListFlowFactory = walletAccountListFlowFactory,
|
||||
flowProducerTools = flowProducerTools,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
walletAccountListFlowFactory = walletAccountListFlowFactory,
|
||||
dispatchers = TestingCoroutineDispatcherProvider(),
|
||||
)
|
||||
|
||||
|
|
@ -46,14 +46,14 @@ class DefaultMultiAccountListProducerTest {
|
|||
|
||||
@AfterEach
|
||||
fun tearDownEach() {
|
||||
clearMocks(userWalletsStore, walletAccountListFlowFactory)
|
||||
clearMocks(userWalletsListRepository, walletAccountListFlowFactory)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun produce() = runTest {
|
||||
// Arrange
|
||||
val userWalletsFlow = MutableStateFlow(value = listOf(userWallet))
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
val accountList = AccountList.empty(userWalletId)
|
||||
every { walletAccountListFlowFactory.create(userWalletId) } returns flowOf(accountList)
|
||||
|
|
@ -66,7 +66,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
Truth.assertThat(actual).containsExactly(expected)
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
fun `flow will updated if factoryFlow is updated`() = runTest {
|
||||
// Arrange
|
||||
val userWalletsFlow = MutableStateFlow(value = listOf(userWallet))
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
val accountList = AccountList.empty(userWalletId)
|
||||
val updatedAccountList = AccountList.empty(userWalletId = userWalletId, sortType = TokensSortType.NONE)
|
||||
|
|
@ -98,9 +98,9 @@ class DefaultMultiAccountListProducerTest {
|
|||
Truth.assertThat(secondEmission).containsExactly(listOf(updatedAccountList))
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
fun `flow is filtered the same response`() = runTest {
|
||||
// Arrange
|
||||
val userWalletsFlow = MutableStateFlow(value = listOf(userWallet))
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
val accountList = AccountList.empty(userWalletId)
|
||||
val factoryFlow = MutableStateFlow<AccountList?>(null)
|
||||
|
|
@ -131,9 +131,9 @@ class DefaultMultiAccountListProducerTest {
|
|||
Truth.assertThat(secondEmission).containsExactly(listOf(accountList))
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
fun `flow returns empty list if factory throws exception`() = runTest {
|
||||
// Arrange
|
||||
val userWalletsFlow = MutableStateFlow(value = listOf(userWallet))
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
val exception = RuntimeException("Converter error")
|
||||
every { walletAccountListFlowFactory.create(userWalletId) } throws exception
|
||||
|
|
@ -156,7 +156,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
Truth.assertThat(actual).containsExactly(expected)
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
fun `flow is empty if userWalletsFlow returns empty flow`() = runTest {
|
||||
// Arrange
|
||||
val userWalletsFlow = emptyFlow<List<UserWallet>>()
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
// Act
|
||||
val actual = producer.produce().let(::getEmittedValues)
|
||||
|
|
@ -173,7 +173,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
// Assert
|
||||
Truth.assertThat(actual).isEmpty() // no emissions
|
||||
|
||||
coVerify(exactly = 1) { userWalletsStore.userWallets }
|
||||
coVerify(exactly = 1) { userWalletsListRepository.loadAndGet() }
|
||||
coVerify(inverse = true) { walletAccountListFlowFactory.create(any()) }
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
fun `flow is empty if factory returns empty flow`() = runTest {
|
||||
// Arrange
|
||||
val userWalletsFlow = MutableStateFlow(value = listOf(userWallet))
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
every { walletAccountListFlowFactory.create(userWalletId) } returns emptyFlow()
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
Truth.assertThat(actual).isEmpty() // no emissions
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
}
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
}
|
||||
|
||||
val userWalletsFlow = MutableStateFlow(listOf(userWallet, userWallet2))
|
||||
every { userWalletsStore.userWallets } returns userWalletsFlow
|
||||
every { userWalletsListRepository.loadAndGet() } returns userWalletsFlow
|
||||
|
||||
val accountList = AccountList.empty(userWalletId)
|
||||
every { walletAccountListFlowFactory.create(userWalletId) } returns flowOf(accountList)
|
||||
|
|
@ -219,7 +219,7 @@ class DefaultMultiAccountListProducerTest {
|
|||
Truth.assertThat(actual).isEmpty() // no emissions
|
||||
|
||||
coVerify(ordering = Ordering.SEQUENCE) {
|
||||
userWalletsStore.userWallets
|
||||
userWalletsListRepository.loadAndGet()
|
||||
walletAccountListFlowFactory.create(userWalletId)
|
||||
walletAccountListFlowFactory.create(userWalletId2)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import com.tangem.common.test.domain.wallet.MockUserWalletFactory
|
|||
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.datasource.local.token.UserTokensResponseStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.card.configs.GenericCardConfig
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.core.flow.FlowProducerTools
|
||||
import com.tangem.domain.models.account.DerivationIndex
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
|
|
@ -35,23 +35,23 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
private val cryptoCurrencyFactory = MockCryptoCurrencyFactory()
|
||||
|
||||
private val params = MultiWalletCryptoCurrenciesProducer.Params(userWalletId = userWallet.walletId)
|
||||
private val userWalletsStore: UserWalletsStore = mockk(relaxUnitFun = true)
|
||||
private val userWalletsListRepository: UserWalletsListRepository = mockk(relaxUnitFun = true)
|
||||
private val userTokensResponseStore: UserTokensResponseStore = mockk(relaxUnitFun = true)
|
||||
private val responseCryptoCurrenciesFactory: ResponseCryptoCurrenciesFactory = mockk()
|
||||
private val flowProducerTools: FlowProducerTools = mockk()
|
||||
|
||||
private val producer = DefaultMultiWalletCryptoCurrenciesProducer(
|
||||
params = params,
|
||||
userWalletsStore = userWalletsStore,
|
||||
flowProducerTools = flowProducerTools,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
userTokensResponseStore = userTokensResponseStore,
|
||||
responseCryptoCurrenciesFactory = responseCryptoCurrenciesFactory,
|
||||
flowProducerTools = flowProducerTools,
|
||||
dispatchers = TestingCoroutineDispatcherProvider(),
|
||||
)
|
||||
|
||||
@BeforeEach
|
||||
fun resetMocks() {
|
||||
clearMocks(userWalletsStore, userTokensResponseStore, responseCryptoCurrenciesFactory)
|
||||
clearMocks(userWalletsListRepository, userTokensResponseStore, responseCryptoCurrenciesFactory)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -59,7 +59,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
// Arrange
|
||||
val userTokensResponseFlow = flowOf<UserTokensResponse?>(null)
|
||||
|
||||
every { userWalletsStore.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow
|
||||
|
||||
// Act
|
||||
|
|
@ -72,7 +72,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
Truth.assertThat(actual.first()).isEqualTo(expected)
|
||||
|
||||
verifyOrder {
|
||||
userWalletsStore.getSyncStrict(params.userWalletId)
|
||||
userWalletsListRepository.getSyncStrict(params.userWalletId)
|
||||
userTokensResponseStore.get(params.userWalletId)
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
cryptoCurrencyFactory.createCoin(Blockchain.Bitcoin),
|
||||
)
|
||||
|
||||
every { userWalletsStore.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow
|
||||
|
||||
every {
|
||||
|
|
@ -146,7 +146,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
Truth.assertThat(actual1.first()).isEqualTo(expected1)
|
||||
|
||||
verifyOrder {
|
||||
userWalletsStore.getSyncStrict(params.userWalletId)
|
||||
userWalletsListRepository.getSyncStrict(params.userWalletId)
|
||||
userTokensResponseStore.get(params.userWalletId)
|
||||
responseCryptoCurrenciesFactory.createCurrencies(
|
||||
response = userTokensResponse,
|
||||
|
|
@ -188,7 +188,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
|
||||
val cryptoCurrencies = emptySet<CryptoCurrency>()
|
||||
|
||||
every { userWalletsStore.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow
|
||||
|
||||
every {
|
||||
|
|
@ -213,7 +213,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
Truth.assertThat(actual1.first()).isEqualTo(expected1)
|
||||
|
||||
verifyOrder {
|
||||
userWalletsStore.getSyncStrict(params.userWalletId)
|
||||
userWalletsListRepository.getSyncStrict(params.userWalletId)
|
||||
userTokensResponseStore.get(params.userWalletId)
|
||||
responseCryptoCurrenciesFactory.createCurrencies(
|
||||
response = userTokensResponse,
|
||||
|
|
@ -257,7 +257,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
}
|
||||
.buffer(capacity = 5)
|
||||
|
||||
every { userWalletsStore.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userTokensResponseStore.get(params.userWalletId) } returns userTokensResponseFlow
|
||||
|
||||
every {
|
||||
|
|
@ -279,7 +279,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
Truth.assertThat(actual1.first()).isEqualTo(expected1)
|
||||
|
||||
verifyOrder {
|
||||
userWalletsStore.getSyncStrict(params.userWalletId)
|
||||
userWalletsListRepository.getSyncStrict(params.userWalletId)
|
||||
userTokensResponseStore.get(params.userWalletId)
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +304,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
@Test
|
||||
fun `flow is empty if store returns empty flow`() = runTest {
|
||||
// Arrange
|
||||
every { userWalletsStore.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns userWallet
|
||||
every { userTokensResponseStore.get(params.userWalletId) } returns emptyFlow()
|
||||
|
||||
// Act
|
||||
|
|
@ -316,7 +316,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
Truth.assertThat(actual.first()).isEqualTo(expected)
|
||||
|
||||
verifyOrder {
|
||||
userWalletsStore.getSyncStrict(params.userWalletId)
|
||||
userWalletsListRepository.getSyncStrict(params.userWalletId)
|
||||
userTokensResponseStore.get(params.userWalletId)
|
||||
}
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
every { isMultiCurrency } returns false
|
||||
}
|
||||
|
||||
every { userWalletsStore.getSyncStrict(params.userWalletId) } returns mockUserWallet
|
||||
every { userWalletsListRepository.getSyncStrict(params.userWalletId) } returns mockUserWallet
|
||||
|
||||
// Act
|
||||
val actual = runCatching { producer.produce() }.exceptionOrNull()
|
||||
|
|
@ -345,7 +345,7 @@ internal class DefaultMultiWalletCryptoCurrenciesProducerTest {
|
|||
Truth.assertThat(actual).isInstanceOf(expected::class.java)
|
||||
Truth.assertThat(actual).hasMessageThat().isEqualTo(expected.message)
|
||||
|
||||
verifyOrder { userWalletsStore.getSyncStrict(params.userWalletId) }
|
||||
verifyOrder { userWalletsListRepository.getSyncStrict(params.userWalletId) }
|
||||
|
||||
verify(inverse = true) {
|
||||
userTokensResponseStore.get(any())
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import com.tangem.data.account.store.AccountsResponseStore
|
|||
import com.tangem.data.account.store.AccountsResponseStoreFactory
|
||||
import com.tangem.data.common.currency.CardCryptoCurrencyFactory
|
||||
import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResponse
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.account.models.AccountList
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.models.wallet.isMultiCurrency
|
||||
|
|
@ -29,7 +29,7 @@ import org.junit.jupiter.api.TestInstance
|
|||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class WalletAccountListFlowFactoryTest {
|
||||
|
||||
private val userWalletsStore: UserWalletsStore = mockk()
|
||||
private val userWalletsListRepository: UserWalletsListRepository = mockk()
|
||||
private val accountsResponseStoreFactory: AccountsResponseStoreFactory = mockk()
|
||||
private val accountsResponseStore: AccountsResponseStore = mockk()
|
||||
private val accountsResponseStoreFlow = MutableStateFlow<GetWalletAccountsResponse?>(value = null)
|
||||
|
|
@ -40,7 +40,7 @@ class WalletAccountListFlowFactoryTest {
|
|||
private val cardCryptoCurrencyFactory: CardCryptoCurrencyFactory = mockk()
|
||||
|
||||
private val factory = WalletAccountListFlowFactory(
|
||||
userWalletsStore = userWalletsStore,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
accountsResponseStoreFactory = accountsResponseStoreFactory,
|
||||
accountListConverterFactory = accountListConverterFactory,
|
||||
cardCryptoCurrencyFactory = cardCryptoCurrencyFactory,
|
||||
|
|
@ -52,7 +52,7 @@ class WalletAccountListFlowFactoryTest {
|
|||
@AfterEach
|
||||
fun tearDownEach() {
|
||||
clearMocks(
|
||||
userWalletsStore,
|
||||
userWalletsListRepository,
|
||||
accountsResponseStoreFactory,
|
||||
accountsResponseStore,
|
||||
accountListConverterFactory,
|
||||
|
|
@ -70,7 +70,7 @@ class WalletAccountListFlowFactoryTest {
|
|||
every { this@mockk.isMultiCurrency } returns true
|
||||
}
|
||||
|
||||
every { userWalletsStore.getSyncStrict(userWalletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(userWalletId) } returns userWallet
|
||||
|
||||
val accountsResponse = createGetWalletAccountsResponse(userWalletId)
|
||||
every { accountsResponseStoreFactory.create(userWalletId) } returns accountsResponseStore
|
||||
|
|
@ -105,7 +105,7 @@ class WalletAccountListFlowFactoryTest {
|
|||
fun `create for single wallet`() = runTest {
|
||||
val userWallet = MockUserWalletFactory.create().copy(isMultiCurrency = false)
|
||||
|
||||
every { userWalletsStore.getSyncStrict(userWallet.walletId) } returns userWallet
|
||||
every { userWalletsListRepository.getSyncStrict(userWallet.walletId) } returns userWallet
|
||||
|
||||
val currency = cryptoCurrencyFactory.ethereum
|
||||
every { cardCryptoCurrencyFactory.createPrimaryCurrencyForSingleCurrencyCard(userWallet) } returns currency
|
||||
|
|
@ -134,7 +134,7 @@ class WalletAccountListFlowFactoryTest {
|
|||
fun `flow is created for single wallet with token`() = runTest {
|
||||
val nodl = MockUserWalletFactory.createSingleWalletWithToken()
|
||||
|
||||
every { userWalletsStore.getSyncStrict(nodl.walletId) } returns nodl
|
||||
every { userWalletsListRepository.getSyncStrict(nodl.walletId) } returns nodl
|
||||
|
||||
val currencies = cryptoCurrencyFactory.ethereumAndStellar.toSet()
|
||||
every {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResp
|
|||
import com.tangem.datasource.api.tangemTech.models.account.GetWalletArchivedAccountsResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.account.WalletAccountDTO
|
||||
import com.tangem.datasource.local.datastore.RuntimeStateStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.account.models.AccountList
|
||||
import com.tangem.domain.account.models.ArchivedAccount
|
||||
import com.tangem.domain.models.account.Account.CryptoPortfolio
|
||||
|
|
@ -52,7 +51,6 @@ class DefaultAccountsCRUDRepositoryTest {
|
|||
private val archivedAccountsInnerStore = RuntimeStateStore<List<ArchivedAccount>?>(defaultValue = null)
|
||||
private val archivedAccountsStore = ArchivedAccountsStore(runtimeStore = archivedAccountsInnerStore)
|
||||
|
||||
private val userWalletsStore: UserWalletsStore = mockk()
|
||||
private val userTokensSaver: UserTokensSaver = mockk()
|
||||
private val archivedAccountsETagStore: RuntimeStateStore<Map<String, String?>> = mockk(relaxUnitFun = true)
|
||||
|
||||
|
|
@ -67,7 +65,6 @@ class DefaultAccountsCRUDRepositoryTest {
|
|||
walletAccountsSaver = walletAccountsSaver,
|
||||
accountsResponseStoreFactory = accountsResponseStoreFactory,
|
||||
archivedAccountsStoreFactory = archivedAccountsStoreFactory,
|
||||
userWalletsStore = userWalletsStore,
|
||||
userTokensSaver = userTokensSaver,
|
||||
archivedAccountsETagStore = archivedAccountsETagStore,
|
||||
convertersContainer = convertersContainer,
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import com.tangem.data.common.currency.UserTokensResponseFactory
|
|||
import com.tangem.data.common.network.NetworkFactory
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.datasource.api.tangemTech.models.account.GetWalletAccountsResponse
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.account.models.AccountList
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.models.account.Account
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
|
@ -23,14 +23,14 @@ import org.junit.jupiter.api.TestInstance
|
|||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class DefaultWalletAccountsResponseFactoryTest {
|
||||
|
||||
private val userWalletsStore = mockk<UserWalletsStore>()
|
||||
private val userWalletsListRepository = mockk<UserWalletsListRepository>()
|
||||
private val cryptoPortfolioCF = mockk<CryptoPortfolioConverter.Factory>()
|
||||
private val cryptoPortfolioConverter = mockk<CryptoPortfolioConverter>()
|
||||
private val userTokensResponseFactory = mockk<UserTokensResponseFactory>()
|
||||
private val networkFactory = mockk<NetworkFactory>()
|
||||
|
||||
private val factory = DefaultWalletAccountsResponseFactory(
|
||||
userWalletsStore = userWalletsStore,
|
||||
userWalletsListRepository = userWalletsListRepository,
|
||||
cryptoPortfolioCF = cryptoPortfolioCF,
|
||||
userTokensResponseFactory = userTokensResponseFactory,
|
||||
networkFactory = networkFactory,
|
||||
|
|
@ -46,7 +46,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
@AfterEach
|
||||
fun tearDownEach() {
|
||||
clearMocks(
|
||||
userWalletsStore,
|
||||
userWalletsListRepository,
|
||||
cryptoPortfolioCF,
|
||||
cryptoPortfolioConverter,
|
||||
userTokensResponseFactory,
|
||||
|
|
@ -63,7 +63,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
tokens = emptyList(),
|
||||
)
|
||||
|
||||
coEvery { userWalletsStore.getSyncOrNull(userWalletId) } returns null
|
||||
coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns null
|
||||
every {
|
||||
userTokensResponseFactory.createDefaultResponse(
|
||||
userWallet = null,
|
||||
|
|
@ -89,7 +89,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
Truth.assertThat(actual).isEqualTo(expected)
|
||||
|
||||
coVerifyOrder {
|
||||
userWalletsStore.getSyncOrNull(userWalletId)
|
||||
userWalletsListRepository.getSyncOrNull(userWalletId)
|
||||
userTokensResponseFactory.createDefaultResponse(
|
||||
userWallet = null,
|
||||
networkFactory = networkFactory,
|
||||
|
|
@ -105,7 +105,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
every { walletId } returns userWalletId
|
||||
}
|
||||
|
||||
coEvery { userWalletsStore.getSyncOrNull(userWalletId) } returns userWallet
|
||||
coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet
|
||||
|
||||
val accounts = AccountList.empty(userWallet.walletId).accounts
|
||||
.filterIsInstance<Account.CryptoPortfolio>()
|
||||
|
|
@ -145,7 +145,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
Truth.assertThat(actual).isEqualTo(expected)
|
||||
|
||||
coVerifyOrder {
|
||||
userWalletsStore.getSyncOrNull(userWalletId)
|
||||
userWalletsListRepository.getSyncOrNull(userWalletId)
|
||||
cryptoPortfolioConverter.convertListBack(accounts)
|
||||
userTokensResponseFactory.createDefaultResponse(
|
||||
userWallet = userWallet,
|
||||
|
|
@ -165,7 +165,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
val accounts = AccountList.empty(userWallet.walletId).accounts
|
||||
.filterIsInstance<Account.CryptoPortfolio>()
|
||||
|
||||
coEvery { userWalletsStore.getSyncOrNull(userWalletId) } returns userWallet
|
||||
coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet
|
||||
|
||||
val defaultResponse = UserTokensResponse(
|
||||
group = UserTokensResponse.GroupType.NETWORK,
|
||||
|
|
@ -206,7 +206,7 @@ class DefaultWalletAccountsResponseFactoryTest {
|
|||
val userWallet = mockk<UserWallet>(relaxed = true) {
|
||||
every { walletId } returns userWalletId
|
||||
}
|
||||
coEvery { userWalletsStore.getSyncOrNull(userWalletId) } returns userWallet
|
||||
coEvery { userWalletsListRepository.getSyncOrNull(userWalletId) } returns userWallet
|
||||
|
||||
val userTokensResponse = UserTokensResponse(
|
||||
group = UserTokensResponse.GroupType.NETWORK,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue