From d061220486728b6873cd2fe5e3db1058d0b2ab8c Mon Sep 17 00:00:00 2001 From: Isabel Martin Date: Mon, 7 Oct 2024 11:37:42 -0700 Subject: [PATCH] MBL-1767: SegmentTrackingClient migration to RXJava2 (#2145) --- .../com/kickstarter/ApplicationModule.java | 6 ++--- .../java/com/kickstarter/libs/KSCurrency.kt | 6 ++--- .../kickstarter/libs/SegmentTrackingClient.kt | 19 ++++++++-------- .../com/kickstarter/libs/TrackingClient.kt | 4 ++-- .../com/kickstarter/libs/braze/BrazeClient.kt | 4 ++-- .../libs/braze/InAppCustomListener.kt | 4 ++-- .../libs/braze/InAppCustomListenerHandler.kt | 9 +++++--- .../mock/factories/ConfigFactory.kt | 3 +++ .../java/com/kickstarter/KSCurrencyTest.kt | 6 ++--- .../com/kickstarter/KSRobolectricTestCase.kt | 17 +++++--------- .../PledgedProjectsOverviewViewModelTest.kt | 12 +++++----- .../libs/InAppCustomListenerHandlerTest.kt | 8 +++---- .../kickstarter/libs/MockTrackingClient.kt | 8 +++---- .../java/com/kickstarter/libs/SegmentTest.kt | 22 +++++++++---------- .../libs/utils/ProjectViewUtilsTest.kt | 4 ++-- .../viewmodels/ChangePasswordViewModelTest.kt | 8 +++---- .../viewmodels/CreatePasswordViewModelTest.kt | 8 +++---- .../ProjectOverviewViewModelTest.kt | 3 ++- .../viewmodels/SettingsViewModelTest.kt | 7 +++--- 19 files changed, 80 insertions(+), 78 deletions(-) diff --git a/app/src/main/java/com/kickstarter/ApplicationModule.java b/app/src/main/java/com/kickstarter/ApplicationModule.java index 006c9e92cd..e465250092 100644 --- a/app/src/main/java/com/kickstarter/ApplicationModule.java +++ b/app/src/main/java/com/kickstarter/ApplicationModule.java @@ -427,9 +427,9 @@ Application provideApplication() { @Singleton SegmentTrackingClient provideSegmentTrackingClient( final @ApplicationContext @NonNull Context context, - final @NonNull CurrentUserType currentUser, + final @NonNull CurrentUserTypeV2 currentUser, final @NonNull Build build, - final @NonNull CurrentConfigType currentConfig, + final @NonNull CurrentConfigTypeV2 currentConfig, final @NonNull FeatureFlagClientType featureFlagClient) { return new SegmentTrackingClient(build, context, currentConfig, currentUser, featureFlagClient, PreferenceManager.getDefaultSharedPreferences(context)); } @@ -574,7 +574,7 @@ static Gson provideGson() { @Provides @Singleton - static KSCurrency provideKSCurrency(final @NonNull CurrentConfigType currentConfig) { + static KSCurrency provideKSCurrency(final @NonNull CurrentConfigTypeV2 currentConfig) { return new KSCurrency(currentConfig); } diff --git a/app/src/main/java/com/kickstarter/libs/KSCurrency.kt b/app/src/main/java/com/kickstarter/libs/KSCurrency.kt index 2b1ee6249d..d78b0181ba 100644 --- a/app/src/main/java/com/kickstarter/libs/KSCurrency.kt +++ b/app/src/main/java/com/kickstarter/libs/KSCurrency.kt @@ -30,7 +30,7 @@ fun KSCurrency?.getCurrencySymbols(project: Project): Pair { return currencySymbolStartAndEnd } -class KSCurrency(private val currentConfig: CurrentConfigType) { +class KSCurrency(private val currentConfig: CurrentConfigTypeV2) { /** * Returns a currency string appropriate to the user's locale and location relative to a project. * @@ -116,8 +116,8 @@ class KSCurrency(private val currentConfig: CurrentConfigType) { fun currencyNeedsCode(country: Country, excludeCurrencyCode: Boolean): Boolean { val countryIsUS = country === Country.US val config = currentConfig.observable() - .toBlocking() - .first() + .blockingFirst() + val currencyNeedsCode = config.currencyNeedsCode(country.currencySymbol) val userInUS = config.countryCode() == Country.US.countryCode return if (userInUS && excludeCurrencyCode && countryIsUS) { diff --git a/app/src/main/java/com/kickstarter/libs/SegmentTrackingClient.kt b/app/src/main/java/com/kickstarter/libs/SegmentTrackingClient.kt index 09ca08c2cb..78d5827741 100644 --- a/app/src/main/java/com/kickstarter/libs/SegmentTrackingClient.kt +++ b/app/src/main/java/com/kickstarter/libs/SegmentTrackingClient.kt @@ -6,7 +6,6 @@ import com.kickstarter.libs.braze.BrazeClient import com.kickstarter.libs.featureflag.FeatureFlagClientType import com.kickstarter.libs.utils.Secrets import com.kickstarter.libs.utils.extensions.isKSApplication -import com.kickstarter.libs.utils.extensions.isNotNull import com.kickstarter.models.User import com.kickstarter.models.extensions.NAME import com.kickstarter.models.extensions.getTraits @@ -19,15 +18,15 @@ import com.segment.analytics.Traits import com.segment.analytics.android.integrations.appboy.AppboyIntegration import com.segment.analytics.integrations.BasePayload import com.segment.analytics.integrations.IdentifyPayload -import rx.android.schedulers.AndroidSchedulers -import rx.schedulers.Schedulers +import io.reactivex.android.schedulers.AndroidSchedulers +import io.reactivex.schedulers.Schedulers import timber.log.Timber open class SegmentTrackingClient( build: Build, private val context: Context, - currentConfig: CurrentConfigType, - currentUser: CurrentUserType, + currentConfig: CurrentConfigTypeV2, + currentUser: CurrentUserTypeV2, ffClient: FeatureFlagClientType, preference: SharedPreferences ) : TrackingClient(context, currentUser, build, currentConfig, ffClient, preference) { @@ -44,7 +43,7 @@ open class SegmentTrackingClient( this.currentConfig.observable() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe { + .map { this.config = it if (calledFromOnCreate) { privateInitializer() @@ -55,14 +54,16 @@ open class SegmentTrackingClient( } } } + .subscribe() this.currentUser.observable() - .filter { it.isNotNull() } - .map { requireNotNull(it) } - .subscribe { + .filter { it.isPresent() } + .map { requireNotNull(it.getValue()) } + .map { this.loggedInUser = it identify(it) } + .subscribe() } override fun initialize() { diff --git a/app/src/main/java/com/kickstarter/libs/TrackingClient.kt b/app/src/main/java/com/kickstarter/libs/TrackingClient.kt index 39c1a88f86..712d62cbb7 100644 --- a/app/src/main/java/com/kickstarter/libs/TrackingClient.kt +++ b/app/src/main/java/com/kickstarter/libs/TrackingClient.kt @@ -24,9 +24,9 @@ import javax.inject.Inject abstract class TrackingClient( @param:ApplicationContext private val context: Context, - @set:Inject var currentUser: CurrentUserType, + @set:Inject var currentUser: CurrentUserTypeV2, @set:Inject var build: Build, - @set:Inject var currentConfig: CurrentConfigType, + @set:Inject var currentConfig: CurrentConfigTypeV2, @set:Inject var ffClient: FeatureFlagClientType, @set:Inject var sharedPreferences: SharedPreferences ) : TrackingClientType() { diff --git a/app/src/main/java/com/kickstarter/libs/braze/BrazeClient.kt b/app/src/main/java/com/kickstarter/libs/braze/BrazeClient.kt index 6812f94421..91d9496b5a 100644 --- a/app/src/main/java/com/kickstarter/libs/braze/BrazeClient.kt +++ b/app/src/main/java/com/kickstarter/libs/braze/BrazeClient.kt @@ -11,7 +11,7 @@ import com.braze.support.BrazeLogger import com.braze.ui.inappmessage.BrazeInAppMessageManager import com.google.firebase.messaging.RemoteMessage import com.kickstarter.libs.Build -import com.kickstarter.libs.CurrentUserType +import com.kickstarter.libs.CurrentUserTypeV2 import com.kickstarter.libs.utils.Secrets import com.kickstarter.libs.utils.extensions.isKSApplication import com.kickstarter.libs.utils.extensions.registerActivityLifecycleCallbacks @@ -151,7 +151,7 @@ open class BrazeClient( * on the `onIntegrationReady` callback */ companion object { - fun setInAppCustomListener(currentUser: CurrentUserType, build: Build) { + fun setInAppCustomListener(currentUser: CurrentUserTypeV2, build: Build) { BrazeInAppMessageManager.getInstance().setCustomInAppMessageManagerListener(InAppCustomListener(currentUser, build)) } } diff --git a/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListener.kt b/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListener.kt index 56e4b5e6b5..7143a80bbd 100644 --- a/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListener.kt +++ b/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListener.kt @@ -5,7 +5,7 @@ import com.braze.models.inappmessage.IInAppMessage import com.braze.ui.inappmessage.InAppMessageOperation import com.braze.ui.inappmessage.listeners.IInAppMessageManagerListener import com.kickstarter.libs.Build -import com.kickstarter.libs.CurrentUserType +import com.kickstarter.libs.CurrentUserTypeV2 import timber.log.Timber /** @@ -15,7 +15,7 @@ import timber.log.Timber * for now we just need `beforeInAppMessageDisplayed`. */ class InAppCustomListener( - loggedInUser: CurrentUserType, + loggedInUser: CurrentUserTypeV2, private val build: Build ) : IInAppMessageManagerListener { diff --git a/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListenerHandler.kt b/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListenerHandler.kt index 1508032b37..aab7631065 100644 --- a/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListenerHandler.kt +++ b/app/src/main/java/com/kickstarter/libs/braze/InAppCustomListenerHandler.kt @@ -1,20 +1,23 @@ package com.kickstarter.libs.braze -import com.kickstarter.libs.CurrentUserType +import com.kickstarter.libs.CurrentUserTypeV2 import com.kickstarter.models.User class InAppCustomListenerHandler( - private val currentUser: CurrentUserType + private val currentUser: CurrentUserTypeV2 ) { private var loggedInUser: User? = null init { this.currentUser.observable() + .filter { it.isPresent() } + .map { requireNotNull(it.getValue()) } .distinctUntilChanged() - .subscribe { + .map { this.loggedInUser = it } + .subscribe() } /** diff --git a/app/src/main/java/com/kickstarter/mock/factories/ConfigFactory.kt b/app/src/main/java/com/kickstarter/mock/factories/ConfigFactory.kt index 1344b4d5d0..7690802b5b 100644 --- a/app/src/main/java/com/kickstarter/mock/factories/ConfigFactory.kt +++ b/app/src/main/java/com/kickstarter/mock/factories/ConfigFactory.kt @@ -39,6 +39,9 @@ object ConfigFactory { fun configForUSUser(): Config { return config() + .toBuilder() + .countryCode("US") + .build() } fun configForCA(): Config { diff --git a/app/src/test/java/com/kickstarter/KSCurrencyTest.kt b/app/src/test/java/com/kickstarter/KSCurrencyTest.kt index 3e90c6d612..9ad3ee9b1d 100644 --- a/app/src/test/java/com/kickstarter/KSCurrencyTest.kt +++ b/app/src/test/java/com/kickstarter/KSCurrencyTest.kt @@ -1,9 +1,9 @@ package com.kickstarter -import com.kickstarter.libs.CurrentConfigType +import com.kickstarter.libs.CurrentConfigTypeV2 import com.kickstarter.libs.KSCurrency import com.kickstarter.libs.models.Country -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.factories.ConfigFactory.config import com.kickstarter.mock.factories.ProjectFactory.caProject import com.kickstarter.mock.factories.ProjectFactory.project @@ -690,7 +690,7 @@ class KSCurrencyTest : TestCase() { val config = config().toBuilder() .countryCode(countryCode) .build() - val currentConfig: CurrentConfigType = MockCurrentConfig() + val currentConfig: CurrentConfigTypeV2 = MockCurrentConfigV2() currentConfig.config(config) return KSCurrency(currentConfig) } diff --git a/app/src/test/java/com/kickstarter/KSRobolectricTestCase.kt b/app/src/test/java/com/kickstarter/KSRobolectricTestCase.kt index 68cdfa8b2d..bcffbb9b52 100644 --- a/app/src/test/java/com/kickstarter/KSRobolectricTestCase.kt +++ b/app/src/test/java/com/kickstarter/KSRobolectricTestCase.kt @@ -9,12 +9,11 @@ import com.kickstarter.libs.AttributionEvents import com.kickstarter.libs.Environment import com.kickstarter.libs.KSCurrency import com.kickstarter.libs.KSString -import com.kickstarter.libs.MockCurrentUser +import com.kickstarter.libs.MockCurrentUserV2 import com.kickstarter.libs.MockTrackingClient import com.kickstarter.libs.TrackingClientType import com.kickstarter.libs.featureflag.FeatureFlagClientType import com.kickstarter.libs.utils.Secrets -import com.kickstarter.mock.MockCurrentConfig import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.MockFeatureFlagClient import com.kickstarter.mock.factories.ConfigFactory @@ -56,28 +55,24 @@ abstract class KSRobolectricTestCase : TestCase() { super.setUp() val mockApolloClientV2 = MockApolloClientV2() - val mockCurrentConfig = MockCurrentConfig() val mockCurrentConfigV2 = MockCurrentConfigV2() val mockFeatureFlagClient = MockFeatureFlagClient() - val segmentTestClient = segmentTrackingClient(mockCurrentConfig, mockFeatureFlagClient) + val segmentTestClient = segmentTrackingClient(mockCurrentConfigV2, mockFeatureFlagClient) val component = DaggerApplicationComponent.builder() .applicationModule(TestApplicationModule(application())) .build() - val config = ConfigFactory.config().toBuilder() - .build() + val config = ConfigFactory.configForUSUser() - mockCurrentConfig.config(config) mockCurrentConfigV2.config(config) environment = component.environment().toBuilder() - .ksCurrency(KSCurrency(mockCurrentConfig)) .apiClient(MockApiClient()) .apolloClient(MockApolloClient()) .apolloClientV2(mockApolloClientV2) - .currentConfig(mockCurrentConfig) .currentConfig2(mockCurrentConfigV2) + .ksCurrency(KSCurrency(mockCurrentConfigV2)) .stripe(Stripe(context(), Secrets.StripePublishableKey.STAGING)) .analytics(AnalyticEvents(listOf(segmentTestClient))) .attributionEvents(AttributionEvents(mockApolloClientV2)) @@ -100,11 +95,11 @@ abstract class KSRobolectricTestCase : TestCase() { protected fun ksString() = KSString(application().packageName, application().resources) - private fun segmentTrackingClient(mockCurrentConfig: MockCurrentConfig, ffClient: FeatureFlagClientType): MockTrackingClient { + private fun segmentTrackingClient(mockCurrentConfig: MockCurrentConfigV2, ffClient: FeatureFlagClientType): MockTrackingClient { segmentTrack = TestSubscriber() segmentIdentify = TestSubscriber() val segmentTrackingClient = MockTrackingClient( - MockCurrentUser(), + MockCurrentUserV2(), mockCurrentConfig, TrackingClientType.Type.SEGMENT, ffClient diff --git a/app/src/test/java/com/kickstarter/features/pledgedprojectsoverview/viewmodel/PledgedProjectsOverviewViewModelTest.kt b/app/src/test/java/com/kickstarter/features/pledgedprojectsoverview/viewmodel/PledgedProjectsOverviewViewModelTest.kt index 6a064efc74..852e642a43 100644 --- a/app/src/test/java/com/kickstarter/features/pledgedprojectsoverview/viewmodel/PledgedProjectsOverviewViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/features/pledgedprojectsoverview/viewmodel/PledgedProjectsOverviewViewModelTest.kt @@ -9,11 +9,11 @@ import com.kickstarter.features.pledgedprojectsoverview.data.PPOCardFactory import com.kickstarter.features.pledgedprojectsoverview.data.PledgedProjectsOverviewEnvelope import com.kickstarter.features.pledgedprojectsoverview.data.PledgedProjectsOverviewQueryData import com.kickstarter.libs.AnalyticEvents -import com.kickstarter.libs.MockCurrentUser +import com.kickstarter.libs.MockCurrentUserV2 import com.kickstarter.libs.MockTrackingClient import com.kickstarter.libs.TrackingClientType import com.kickstarter.libs.utils.EventName -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.MockFeatureFlagClient import com.kickstarter.mock.factories.ProjectFactory import com.kickstarter.mock.factories.UserFactory @@ -204,8 +204,8 @@ class PledgedProjectsOverviewViewModelTest : KSRobolectricTestCase() { val mutableTotalAlerts = MutableStateFlow(0) val user = UserFactory.user() val trackingClient = MockTrackingClient( - MockCurrentUser(user), - MockCurrentConfig(), + MockCurrentUserV2(user), + MockCurrentConfigV2(), TrackingClientType.Type.SEGMENT, MockFeatureFlagClient() ) @@ -246,8 +246,8 @@ class PledgedProjectsOverviewViewModelTest : KSRobolectricTestCase() { val totalAlertsList = mutableListOf() val user = UserFactory.user() val trackingClient = MockTrackingClient( - MockCurrentUser(user), - MockCurrentConfig(), + MockCurrentUserV2(user), + MockCurrentConfigV2(), TrackingClientType.Type.SEGMENT, MockFeatureFlagClient() ) diff --git a/app/src/test/java/com/kickstarter/libs/InAppCustomListenerHandlerTest.kt b/app/src/test/java/com/kickstarter/libs/InAppCustomListenerHandlerTest.kt index 2b85ab5d2e..0a2013c617 100644 --- a/app/src/test/java/com/kickstarter/libs/InAppCustomListenerHandlerTest.kt +++ b/app/src/test/java/com/kickstarter/libs/InAppCustomListenerHandlerTest.kt @@ -124,7 +124,7 @@ class InAppCustomListenerHandlerTest : KSRobolectricTestCase() { @Test fun testMessageShouldShow_True() { val user = UserFactory.user() - val mockUser = MockCurrentUser(user) + val mockUser = MockCurrentUserV2(user) val handler = InAppCustomListenerHandler(mockUser) Thread.sleep(100) // wait a bit until InAppCustomListenerHandler.init block executed @@ -133,7 +133,7 @@ class InAppCustomListenerHandlerTest : KSRobolectricTestCase() { @Test fun testMessageShouldShow_False() { - val mockUser = MockCurrentUser() // - no user logged in + val mockUser = MockCurrentUserV2() // - no user logged in val handler = InAppCustomListenerHandler(mockUser) Thread.sleep(100) // wait a bit until InAppCustomListenerHandler.init block executed @@ -143,7 +143,7 @@ class InAppCustomListenerHandlerTest : KSRobolectricTestCase() { @Test fun testInAppCustomListener_DisplayNow() { val user = UserFactory.user() - val mockUser = MockCurrentUser(user) + val mockUser = MockCurrentUserV2(user) val listener = InAppCustomListener(mockUser, build) Thread.sleep(100) // wait a bit until InAppCustomListener.init block executed @@ -152,7 +152,7 @@ class InAppCustomListenerHandlerTest : KSRobolectricTestCase() { @Test fun testInAppCustomListener_Discard() { - val mockUser = MockCurrentUser() // - no user logged in + val mockUser = MockCurrentUserV2() // - no user logged in val listener = InAppCustomListener(mockUser, build) Thread.sleep(100) // wait a bit until InAppCustomListener.init block executed diff --git a/app/src/test/java/com/kickstarter/libs/MockTrackingClient.kt b/app/src/test/java/com/kickstarter/libs/MockTrackingClient.kt index d69a5ffae8..2e5d23f039 100644 --- a/app/src/test/java/com/kickstarter/libs/MockTrackingClient.kt +++ b/app/src/test/java/com/kickstarter/libs/MockTrackingClient.kt @@ -9,8 +9,8 @@ import rx.subjects.BehaviorSubject import rx.subjects.PublishSubject class MockTrackingClient( - currentUser: CurrentUserType, - currentConfig: CurrentConfigType, + currentUser: CurrentUserTypeV2, + currentConfig: CurrentConfigTypeV2, private val type: Type, private val ffClient: FeatureFlagClientType ) : TrackingClientType() { @@ -47,8 +47,8 @@ class MockTrackingClient( val identifiedUser = BehaviorSubject.create() init { - currentUser.observable().subscribe { user: User? -> propagateUser(user) } - currentConfig.observable().subscribe { c: Config? -> config = c } + currentUser.observable().map { propagateUser(it.getValue()) }.subscribe() + currentConfig.observable().map { c: Config? -> config = c }.subscribe() } override fun track(eventName: String, additionalProperties: Map) { diff --git a/app/src/test/java/com/kickstarter/libs/SegmentTest.kt b/app/src/test/java/com/kickstarter/libs/SegmentTest.kt index ee495fef33..7dc054380e 100644 --- a/app/src/test/java/com/kickstarter/libs/SegmentTest.kt +++ b/app/src/test/java/com/kickstarter/libs/SegmentTest.kt @@ -49,7 +49,7 @@ import com.kickstarter.libs.utils.EventName.CTA_CLICKED import com.kickstarter.libs.utils.EventName.PAGE_VIEWED import com.kickstarter.libs.utils.EventName.VIDEO_PLAYBACK_COMPLETED import com.kickstarter.libs.utils.EventName.VIDEO_PLAYBACK_STARTED -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.MockFeatureFlagClient import com.kickstarter.mock.factories.AvatarFactory import com.kickstarter.mock.factories.BackingFactory @@ -92,8 +92,8 @@ class SegmentTest : KSRobolectricTestCase() { class MockSegmentTrackingClient( build: Build, context: Context, - currentConfig: CurrentConfigType, - currentUser: CurrentUserType, + currentConfig: CurrentConfigTypeV2, + currentUser: CurrentUserTypeV2, ffClient: FeatureFlagClientType, mockSharedPref: SharedPreferences ) : SegmentTrackingClient(build, context, currentConfig, currentUser, ffClient, mockSharedPref) { @@ -113,7 +113,7 @@ class SegmentTest : KSRobolectricTestCase() { } } - val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUser(user), mockFeatureFlagClient, mockShared) + val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUserV2(user), mockFeatureFlagClient, mockShared) client.initialize() assertFalse(mockShared.contains(SharedPreferenceKey.CONSENT_MANAGEMENT_PREFERENCE)) assertTrue(client.isEnabled()) @@ -128,7 +128,7 @@ class SegmentTest : KSRobolectricTestCase() { } } - val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUser(user), mockFeatureFlagClient, mockShared) + val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUserV2(user), mockFeatureFlagClient, mockShared) client.initialize() assertFalse(mockShared.contains(SharedPreferenceKey.CONSENT_MANAGEMENT_PREFERENCE)) assertFalse(client.isEnabled()) @@ -144,7 +144,7 @@ class SegmentTest : KSRobolectricTestCase() { } mockShared.edit().putBoolean(SharedPreferenceKey.CONSENT_MANAGEMENT_PREFERENCE, true) - val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUser(user), mockFeatureFlagClient, mockShared) + val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUserV2(user), mockFeatureFlagClient, mockShared) client.initialize() assertTrue(mockShared.contains(SharedPreferenceKey.CONSENT_MANAGEMENT_PREFERENCE)) assertTrue(client.isEnabled()) @@ -161,7 +161,7 @@ class SegmentTest : KSRobolectricTestCase() { mockShared.edit().putBoolean(SharedPreferenceKey.CONSENT_MANAGEMENT_PREFERENCE, false) - val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUser(user), mockFeatureFlagClient, mockShared) + val client = SegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUserV2(user), mockFeatureFlagClient, mockShared) client.initialize() assertTrue(mockShared.contains(SharedPreferenceKey.CONSENT_MANAGEMENT_PREFERENCE)) assertFalse(client.isEnabled()) @@ -172,7 +172,7 @@ class SegmentTest : KSRobolectricTestCase() { val user = UserFactory.user() val mockFeatureFlagClient = MockFeatureFlagClient() - val mockClient = MockSegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUser(user), mockFeatureFlagClient, mockShared) + val mockClient = MockSegmentTrackingClient(build, context, mockCurrentConfig(), MockCurrentUserV2(user), mockFeatureFlagClient, mockShared) mockClient.initialize() assertNotNull(mockClient) assertTrue(mockClient.isEnabled()) @@ -1824,8 +1824,8 @@ class SegmentTest : KSRobolectricTestCase() { } private fun client(user: User?) = MockTrackingClient( - user?.let { MockCurrentUser(it) } - ?: MockCurrentUser(), + user?.let { MockCurrentUserV2(it) } + ?: MockCurrentUserV2(), mockCurrentConfig(), TrackingClientType.Type.SEGMENT, MockFeatureFlagClient() @@ -1977,7 +1977,7 @@ class SegmentTest : KSRobolectricTestCase() { assertEquals(videoPosition, expectedProperties["video_position"]) } - private fun mockCurrentConfig() = MockCurrentConfig().apply { + private fun mockCurrentConfig() = MockCurrentConfigV2().apply { val config = ConfigFactory.configWithFeatureEnabled("android_example_feature") .toBuilder() .abExperiments(mapOf(Pair("android_example_experiment", "control"))) diff --git a/app/src/test/java/com/kickstarter/libs/utils/ProjectViewUtilsTest.kt b/app/src/test/java/com/kickstarter/libs/utils/ProjectViewUtilsTest.kt index cbc195a0a6..672b716f8c 100644 --- a/app/src/test/java/com/kickstarter/libs/utils/ProjectViewUtilsTest.kt +++ b/app/src/test/java/com/kickstarter/libs/utils/ProjectViewUtilsTest.kt @@ -3,7 +3,7 @@ package com.kickstarter.libs.utils import com.kickstarter.KSRobolectricTestCase import com.kickstarter.R import com.kickstarter.libs.KSCurrency -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.factories.ConfigFactory import com.kickstarter.mock.factories.ProjectFactory import com.kickstarter.mock.factories.UserFactory @@ -113,7 +113,7 @@ class ProjectViewUtilsTest : KSRobolectricTestCase() { .countryCode(countryCode) .build() - val currentConfig = MockCurrentConfig() + val currentConfig = MockCurrentConfigV2() currentConfig.config(config) return KSCurrency(currentConfig) diff --git a/app/src/test/java/com/kickstarter/viewmodels/ChangePasswordViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/ChangePasswordViewModelTest.kt index 68dff12621..ac14a6c974 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/ChangePasswordViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/ChangePasswordViewModelTest.kt @@ -4,10 +4,10 @@ import UpdateUserPasswordMutation import com.kickstarter.KSRobolectricTestCase import com.kickstarter.libs.AnalyticEvents import com.kickstarter.libs.Environment -import com.kickstarter.libs.MockCurrentUser +import com.kickstarter.libs.MockCurrentUserV2 import com.kickstarter.libs.MockTrackingClient import com.kickstarter.libs.TrackingClientType -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.MockFeatureFlagClient import com.kickstarter.mock.factories.UserFactory import com.kickstarter.mock.services.MockApolloClientV2 @@ -200,8 +200,8 @@ class ChangePasswordViewModelTest : KSRobolectricTestCase() { } private fun getMockClientWithUser(user: User) = MockTrackingClient( - MockCurrentUser(user), - MockCurrentConfig(), + MockCurrentUserV2(user), + MockCurrentConfigV2(), TrackingClientType.Type.SEGMENT, MockFeatureFlagClient() ).apply { diff --git a/app/src/test/java/com/kickstarter/viewmodels/CreatePasswordViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/CreatePasswordViewModelTest.kt index b320b17126..530f6ca5a7 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/CreatePasswordViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/CreatePasswordViewModelTest.kt @@ -4,11 +4,11 @@ import CreatePasswordMutation import com.kickstarter.KSRobolectricTestCase import com.kickstarter.libs.AnalyticEvents import com.kickstarter.libs.Environment -import com.kickstarter.libs.MockCurrentUser +import com.kickstarter.libs.MockCurrentUserV2 import com.kickstarter.libs.MockTrackingClient import com.kickstarter.libs.TrackingClientType import com.kickstarter.libs.utils.extensions.addToDisposable -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.MockFeatureFlagClient import com.kickstarter.mock.factories.UserFactory import com.kickstarter.mock.services.MockApolloClientV2 @@ -147,8 +147,8 @@ class CreatePasswordViewModelTest : KSRobolectricTestCase() { } private fun getMockClientWithUser(user: User) = MockTrackingClient( - MockCurrentUser(user), - MockCurrentConfig(), + MockCurrentUserV2(user), + MockCurrentConfigV2(), TrackingClientType.Type.SEGMENT, MockFeatureFlagClient() ).apply { diff --git a/app/src/test/java/com/kickstarter/viewmodels/ProjectOverviewViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/ProjectOverviewViewModelTest.kt index 8d7ccc4b1a..1d8683f4a1 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/ProjectOverviewViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/ProjectOverviewViewModelTest.kt @@ -11,6 +11,7 @@ import com.kickstarter.libs.utils.ProgressBarUtils import com.kickstarter.libs.utils.extensions.addToDisposable import com.kickstarter.libs.utils.extensions.deadlineCountdownValue import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.factories.CategoryFactory import com.kickstarter.mock.factories.ConfigFactory import com.kickstarter.mock.factories.LocationFactory @@ -543,7 +544,7 @@ class ProjectOverviewViewModelTest : KSRobolectricTestCase() { // Use a CA project with a MX$ currency val project = ProjectFactory.mxCurrencyCAProject() val config = ConfigFactory.configForUSUser() - val currentConfig = MockCurrentConfig() + val currentConfig = MockCurrentConfigV2() currentConfig.config(config) // Set the current config for a US user. KSCurrency needs this config for conversions. diff --git a/app/src/test/java/com/kickstarter/viewmodels/SettingsViewModelTest.kt b/app/src/test/java/com/kickstarter/viewmodels/SettingsViewModelTest.kt index a7413b5fd9..41a96f1eb4 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/SettingsViewModelTest.kt +++ b/app/src/test/java/com/kickstarter/viewmodels/SettingsViewModelTest.kt @@ -3,12 +3,11 @@ package com.kickstarter.viewmodels import com.kickstarter.KSRobolectricTestCase import com.kickstarter.libs.AnalyticEvents import com.kickstarter.libs.Environment -import com.kickstarter.libs.MockCurrentUser import com.kickstarter.libs.MockCurrentUserV2 import com.kickstarter.libs.MockTrackingClient import com.kickstarter.libs.TrackingClientType import com.kickstarter.libs.utils.extensions.addToDisposable -import com.kickstarter.mock.MockCurrentConfig +import com.kickstarter.mock.MockCurrentConfigV2 import com.kickstarter.mock.MockFeatureFlagClient import com.kickstarter.mock.factories.UserFactory import com.kickstarter.models.User @@ -100,8 +99,8 @@ class SettingsViewModelTest : KSRobolectricTestCase() { } private fun getMockClientWithUser(user: User) = MockTrackingClient( - MockCurrentUser(user), - MockCurrentConfig(), + MockCurrentUserV2(user), + MockCurrentConfigV2(), TrackingClientType.Type.SEGMENT, MockFeatureFlagClient() ).apply {