Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion accounts-demo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ android {
dependencies {
implementation(projects.appCommon)
implementation(projects.accountsJourney)
implementation(projects.accountsUseCase)

implementation(platform(backbase.bom))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.backbase.accounts_demo.journey.accounts
import android.app.Application
import com.backbase.accounts_journey.AccountsJourney
import com.backbase.accounts_journey.routing.AccountsRoutingImpl
import com.backbase.accounts_use_case.AccountDetailUseCaseImpl
import com.backbase.accounts_use_case.AccountSummaryUseCaseImpl
import com.backbase.accounts_journey.data.usecase.AccountDetailUseCaseImpl
import com.backbase.accounts_journey.data.usecase.AccountSummaryUseCaseImpl
import com.backbase.android.client.gen2.arrangementclient2.api.ArrangementsApi
import com.backbase.android.client.gen2.arrangementclient2.api.ProductSummaryApi
import com.backbase.app_common.accounts.accountsModule
Expand Down
1 change: 1 addition & 0 deletions accounts-journey/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation(platform(backbase.bom))
implementation(midTier.bundles.common)
implementation(libs.bundles.navigation)
implementation(clients.arrangements)

coreLibraryDesugaring(libs.coreLibraryDesugaring)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import com.backbase.accounts_journey.generator.AccountSummaryGenerator
import com.backbase.accounts_journey.presentation.accountlist.ui.AccountListFragment
import com.backbase.accounts_use_case.ErrorAccountsUseCase
import com.backbase.accounts_use_case.SuccessAccountsUseCase
import com.backbase.android.test_data.NumberGenerator.randomFloat
import com.backbase.android.test_data.shouldBeDisplayed
import kotlinx.coroutines.ExperimentalCoroutinesApi
import org.junit.Test
import screens.accountListScreen
import java.math.BigDecimal

@OptIn(ExperimentalCoroutinesApi::class)
class AccountsListTests : BaseTest() {
Expand All @@ -33,7 +35,7 @@ class AccountsListTests : BaseTest() {

accountWithName(ACCOUNT_NAME) {
accountNameIsDisplayed()
accountBalanceIsDisplayed(ACCOUNT_BALANCE)
accountBalanceIsDisplayed(ACCOUNT_BALANCE.toString())
}
}
}
Expand Down Expand Up @@ -124,7 +126,7 @@ class AccountsListTests : BaseTest() {

companion object {
const val ACCOUNT_NAME = "Alpha"
const val ACCOUNT_BALANCE = "45.89"
val ACCOUNT_BALANCE = BigDecimal.valueOf(45.89)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has potential precision and unchecked nullability issues. Better to use BigDecimal("45.89") to be exact.

val TEST_ACCOUNTS = AccountSummaryGenerator.generateAccountSummary(
displayName = ACCOUNT_NAME,
availableBalance = ACCOUNT_BALANCE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.backbase.accounts_journey.data.usecase

import com.backbase.accounts_journey.domain.model.account_detail.AccountDetail
import com.backbase.android.client.gen2.arrangementclient2.model.AccountArrangementItem
import dev.drewhamilton.poko.Poko

interface AccountDetailUseCase {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
interface AccountDetailUseCase {
fun interface GetAccountDetailUseCase {

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend this change to enforce the SAM nature of this use-case and name it accordingly.

suspend fun getAccountDetail(params: Params): Result<AccountDetail>
suspend fun getAccountDetail(params: Params): Result<AccountArrangementItem>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
suspend fun getAccountDetail(params: Params): Result<AccountArrangementItem>
suspend operator fun invoke(params: Params): Result<AccountArrangementItem>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operator is also a nice addition here to allow:

val getAccountDetails = GetAccountDetailUseCase { params ->
   ...
}

getAccountDetails(Params{})

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not convinced about exposing client objects directly with the journey's APIs. We risk unnecessarily coupling the client API with journey's API. Clients are generated and inherently produce unstable(especially from past experience) API that strongly tied to the BE. I am not sure it's prudent to strongly couple the 2.

Also keep in mind that for certain BE capabilities, their models don't map 1-to-1 to UI models . BE models will still need some mapping/transformation in the journey in some cases.


@Poko
class Params private constructor(val id: String) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.backbase.accounts_use_case
package com.backbase.accounts_journey.data.usecase

import com.backbase.accounts_journey.common.FailedGetDataException
import com.backbase.accounts_journey.common.NoInternetException
import com.backbase.accounts_journey.common.NoResponseException
import com.backbase.accounts_journey.data.usecase.AccountDetailUseCase
import com.backbase.accounts_journey.domain.model.account_detail.AccountDetail
import com.backbase.accounts_use_case.mapper.mapToDomain
import com.backbase.android.client.gen2.arrangementclient2.api.ArrangementsApi
import com.backbase.android.client.gen2.arrangementclient2.api.ArrangementsApiParams
import com.backbase.android.client.gen2.arrangementclient2.model.AccountArrangementItem
import com.backbase.android.clients.common.CallResult
import com.backbase.android.core.errorhandling.ErrorCodes
import kotlinx.coroutines.CoroutineDispatcher
Expand All @@ -24,7 +22,7 @@ class AccountDetailUseCaseImpl(
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
) : AccountDetailUseCase {

override suspend fun getAccountDetail(params: AccountDetailUseCase.Params): Result<AccountDetail> {
override suspend fun getAccountDetail(params: AccountDetailUseCase.Params): Result<AccountArrangementItem> {
val callResult = withContext(dispatcher) {
arrangementsApi.getArrangementById(
ArrangementsApiParams.GetArrangementById {
Expand All @@ -35,9 +33,7 @@ class AccountDetailUseCaseImpl(

return when (callResult) {
is CallResult.Success -> {
val dataModel = callResult.data
val domainModel = dataModel.mapToDomain()
Result.success(domainModel)
Result.success(callResult.data)
}

is CallResult.Error -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.backbase.accounts_use_case
package com.backbase.accounts_journey.data.usecase

import com.backbase.accounts_journey.common.FailedGetDataException
import com.backbase.accounts_journey.common.NoInternetException
import com.backbase.accounts_journey.common.NoResponseException
import com.backbase.accounts_journey.data.usecase.AccountsUseCase
import com.backbase.accounts_journey.domain.model.account_summary.AccountSummary
import com.backbase.accounts_use_case.mapper.mapToDomain
import com.backbase.android.client.gen2.arrangementclient2.api.ProductSummaryApi
import com.backbase.android.client.gen2.arrangementclient2.api.ProductSummaryApiParams
import com.backbase.android.client.gen2.arrangementclient2.model.ProductSummary
import com.backbase.android.clients.common.CallResult
import com.backbase.android.core.errorhandling.ErrorCodes
import kotlinx.coroutines.CoroutineDispatcher
Expand All @@ -24,9 +22,9 @@ class AccountSummaryUseCaseImpl(
private val ioDispatcher: CoroutineDispatcher = Dispatchers.IO,
) : AccountsUseCase {

private var cache: AccountSummary? = null
private var cache: ProductSummary? = null

override suspend fun getAccountSummary(useCache: Boolean): Result<AccountSummary> {
override suspend fun getAccountSummary(useCache: Boolean): Result<ProductSummary> {
if (useCache && cache != null) {
return Result.success(cache!!)
}
Expand All @@ -39,10 +37,9 @@ class AccountSummaryUseCaseImpl(

return when (callResult) {
is CallResult.Success -> {
val dataModel = callResult.data
val domainModel = dataModel.mapToDomain()
cache = domainModel
Result.success(domainModel)
val data = callResult.data
cache = data
Result.success(data)
}

is CallResult.Error -> {
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same recommendations as AccountDetailUseCase

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.backbase.accounts_journey.data.usecase

import com.backbase.accounts_journey.domain.model.account_summary.AccountSummary
import com.backbase.android.client.gen2.arrangementclient2.model.ProductSummary

/**
* The use cases for the accounts/products.
Expand All @@ -12,7 +12,7 @@ interface AccountsUseCase {
/**
* Method that fetches a list of accounts.
*
* @return an instance of [AccountSummary]
* @return an instance of [ProductSummary]
*/
suspend fun getAccountSummary(useCache: Boolean = true): Result<AccountSummary>
suspend fun getAccountSummary(useCache: Boolean = true): Result<ProductSummary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
suspend fun getAccountSummary(useCache: Boolean = true): Result<ProductSummary>
suspend operator fun invoke(useCache: Boolean = true): Result<ProductSummary>

}
Loading