diff --git a/build.gradle b/build.gradle index ace5743..4829dd8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.8.10' + ext.kotlin_version = '2.0.20' if (!project.hasProperty('version') || project.version.equals('unspecified')) { project.version = '+' } @@ -10,7 +10,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.4.1' + classpath 'com.android.tools.build:gradle:8.1.4' classpath 'com.mparticle:android-kit-plugin:' + project.version classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } @@ -18,7 +18,7 @@ buildscript { plugins { id "org.sonarqube" version "3.5.0.2730" - id "org.jlleitschuh.gradle.ktlint" version "11.2.0" + id "org.jlleitschuh.gradle.ktlint" version "13.0.0" } sonarqube { @@ -30,13 +30,24 @@ sonarqube { } apply plugin: 'org.jlleitschuh.gradle.ktlint' -apply plugin: 'com.mparticle.kit' apply plugin: 'kotlin-android' +apply plugin: 'com.mparticle.kit' android { + namespace 'com.mparticle.kits.appsflyer' + buildFeatures { + buildConfig = true + } defaultConfig { minSdkVersion 19 } + compileOptions { + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = '17' + } testOptions { unitTests.all { jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] @@ -44,6 +55,10 @@ android { } } +ktlint { + android.set(true) +} + dependencies { api 'com.appsflyer:af-android-sdk:6.17.3' testImplementation files('libs/java-json.jar') diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3f391f9..e1bef7e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Jul 11 21:05:38 COT 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index a87918e..ec4a767 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/src/main/kotlin/com/mparticle/kits/AppsFlyerKit.kt b/src/main/kotlin/com/mparticle/kits/AppsFlyerKit.kt index b9b3b92..e49bba7 100644 --- a/src/main/kotlin/com/mparticle/kits/AppsFlyerKit.kt +++ b/src/main/kotlin/com/mparticle/kits/AppsFlyerKit.kt @@ -37,25 +37,30 @@ import org.json.JSONObject import java.math.BigDecimal import java.util.LinkedList - /** * mParticle Kit wrapper for the AppsFlyer SDK */ -class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, - KitIntegration.AttributeListener, KitIntegration.CommerceListener, - AppsFlyerConversionListener, KitIntegration.ActivityListener, KitIntegration.UserAttributeListener { - - - override fun getInstance(): AppsFlyerLib = AppsFlyerLib.getInstance(); +class AppsFlyerKit : + KitIntegration(), + KitIntegration.EventListener, + KitIntegration.AttributeListener, + KitIntegration.CommerceListener, + AppsFlyerConversionListener, + KitIntegration.ActivityListener, + KitIntegration.UserAttributeListener { + override fun getInstance(): AppsFlyerLib = AppsFlyerLib.getInstance() override fun getName() = NAME public override fun onKitCreate( setting: Map?, - context: Context + context: Context, ): List { - AppsFlyerLib.getInstance() - .setDebugLog(MParticle.getInstance()?.environment == MParticle.Environment.Development) + AppsFlyerLib + .getInstance() + .setDebugLog( + MParticle.getInstance()?.environment == MParticle.Environment.Development, + ) settings[DEV_KEY]?.let { AppsFlyerLib.getInstance().init(it, this, context) } val userConsentState = currentUser?.consentState setConsent(userConsentState) @@ -73,35 +78,32 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, this, ReportingMessage.MessageType.APP_STATE_TRANSITION, System.currentTimeMillis(), - null - ) + null, + ), ) return messages } override fun leaveBreadcrumb(breadcrumb: String): List = emptyList() - override fun logError( message: String, - eventData: Map + eventData: Map, ): List = emptyList() - override fun logException( exception: Exception, eventData: Map, - message: String + message: String, ): List = emptyList() override fun logLtvIncrease( valueIncreased: BigDecimal, valueTotal: BigDecimal, eventName: String, - contextInfo: Map + contextInfo: Map, ): List = emptyList() - override fun logEvent(event: CommerceEvent): List { val messages: MutableList = LinkedList() val eventValues: MutableMap = HashMap() @@ -117,7 +119,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, private fun logNotSalesEvent( event: CommerceEvent, - messages: MutableList + messages: MutableList, ) { val eventList = CommerceEventUtils.expand(event) if (eventList.isNotEmpty()) { @@ -136,7 +138,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, event: CommerceEvent, eventValues: MutableMap, productList: MutableList?, - messages: MutableList + messages: MutableList, ) { event.customAttributes?.let { eventValues.putAll(it) } @@ -144,12 +146,15 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, eventValues[CURRENCY] = event.currency } - if (event.productAction == Product.ADD_TO_CART - || event.productAction == Product.ADD_TO_WISHLIST + if (event.productAction == Product.ADD_TO_CART || + event.productAction == Product.ADD_TO_WISHLIST ) { val eventName = - if (event.productAction == Product.ADD_TO_CART) ADD_TO_CART - else ADD_TO_WISH_LIST + if (event.productAction == Product.ADD_TO_CART) { + ADD_TO_CART + } else { + ADD_TO_WISH_LIST + } productList?.iterator()?.forEach { product -> val productEventValues: MutableMap = hashMapOf() @@ -169,8 +174,11 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } } else { val eventName = - if (event.productAction == Product.CHECKOUT) - INITIATED_CHECKOUT else PURCHASE + if (event.productAction == Product.CHECKOUT) { + INITIATED_CHECKOUT + } else { + PURCHASE + } eventValues[CONTENT_ID] = generateProductIdList(event) if (!productList.isNullOrEmpty()) { @@ -199,10 +207,10 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } private fun isSalesEvent(event: CommerceEvent) = - (event.productAction == Product.ADD_TO_CART - || event.productAction == Product.ADD_TO_WISHLIST - || event.productAction == Product.CHECKOUT - || event.productAction == Product.PURCHASE) + event.productAction == Product.ADD_TO_CART || + event.productAction == Product.ADD_TO_WISHLIST || + event.productAction == Product.CHECKOUT || + event.productAction == Product.PURCHASE override fun logEvent(event: MPEvent): List { var hashMap: HashMap? = hashMapOf() @@ -217,10 +225,9 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, override fun logScreen( screenName: String, - eventAttributes: Map + eventAttributes: Map, ): List = emptyList() - override fun setOptOut(optOutStatus: Boolean): List { instance.anonymizeUser(optOutStatus) val messageList: MutableList = LinkedList() @@ -229,48 +236,72 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, this, ReportingMessage.MessageType.OPT_OUT, System.currentTimeMillis(), - null - ).setOptOut(optOutStatus) + null, + ).setOptOut(optOutStatus), ) return messageList } - override fun setUserAttribute(attributeKey: String, attributeValue: String) {} - override fun setUserAttributeList(s: String, list: List) {} + override fun setUserAttribute( + attributeKey: String, + attributeValue: String, + ) {} + + override fun setUserAttributeList( + s: String, + list: List, + ) {} + override fun onIncrementUserAttribute( key: String?, incrementedBy: Number?, value: String?, - user: FilteredMParticleUser? + user: FilteredMParticleUser?, ) { } - override fun onRemoveUserAttribute(key: String?, user: FilteredMParticleUser?) { + override fun onRemoveUserAttribute( + key: String?, + user: FilteredMParticleUser?, + ) { } - override fun onSetUserAttribute(key: String?, value: Any?, user: FilteredMParticleUser?) { + override fun onSetUserAttribute( + key: String?, + value: Any?, + user: FilteredMParticleUser?, + ) { } - override fun onSetUserTag(key: String?, user: FilteredMParticleUser?) { + override fun onSetUserTag( + key: String?, + user: FilteredMParticleUser?, + ) { } override fun onSetUserAttributeList( attributeKey: String?, attributeValueList: MutableList?, - user: FilteredMParticleUser? + user: FilteredMParticleUser?, ) { } override fun onSetAllUserAttributes( userAttributes: MutableMap?, userAttributeLists: MutableMap>?, - user: FilteredMParticleUser? + user: FilteredMParticleUser?, ) { } override fun supportsAttributeLists(): Boolean = true - override fun setAllUserAttributes(map: Map, map1: Map>) {} + + override fun setAllUserAttributes( + map: Map, + map1: Map>, + ) {} + override fun removeUserAttribute(key: String) {} + override fun removeUserIdentity(identityType: MParticle.IdentityType) { with(instance) { if (MParticle.IdentityType.CustomerId == identityType) { @@ -281,7 +312,10 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } } - override fun setUserIdentity(identityType: MParticle.IdentityType, identity: String) { + override fun setUserIdentity( + identityType: MParticle.IdentityType, + identity: String, + ) { with(instance) { if (MParticle.IdentityType.CustomerId == identityType) { setCustomerUserId(identity) @@ -312,13 +346,16 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } catch (e: Exception) { Logger.error( e, - "The AppsFlyer kit was unable to parse the user's ConsentState, consent may not be set correctly on the AppsFlyer SDK" + "The AppsFlyer kit was unable to parse the user's ConsentState, consent may not be set correctly on the AppsFlyer SDK", ) } return topLevelMap } - private fun searchKeyInNestedMap(map: Map<*, *>, key: Any): Any? { + private fun searchKeyInNestedMap( + map: Map<*, *>, + key: Any, + ): Any? { if (map.isNullOrEmpty()) { return null } @@ -337,7 +374,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } catch (e: Exception) { Logger.error( e, - "The AppsFlyer kit threw an exception while searching for the configured consent purpose mapping in the current user's consent status." + "The AppsFlyer kit threw an exception while searching for the configured consent purpose mapping in the current user's consent status.", ) } return null @@ -346,7 +383,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, override fun onConsentStateUpdated( consentState: ConsentState, consentState1: ConsentState, - filteredMParticleUser: FilteredMParticleUser + filteredMParticleUser: FilteredMParticleUser, ) { setConsent(consentState1) } @@ -379,7 +416,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, val clientConsentSettings = parseToNestedMap(consentState.toString()) - parseConsentMapping(settings[consentMapping]).iterator().forEach { currentConsent -> + parseConsentMapping(settings[CONSENT_MAPPING]).iterator().forEach { currentConsent -> val isConsentAvailable = searchKeyInNestedMap(clientConsentSettings, key = currentConsent.key) @@ -422,7 +459,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } catch (jse: JSONException) { Logger.error( jse, - "The AppsFlyer kit threw an exception while searching for the configured consent purpose mapping in the current user's consent status." + "The AppsFlyer kit threw an exception while searching for the configured consent purpose mapping in the current user's consent status.", ) emptyMap() } @@ -445,66 +482,69 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, } } - val result = AttributionResult() - .setParameters(jsonResult) - .setServiceProviderId(configuration.kitId) + val result = + AttributionResult() + .setParameters(jsonResult) + .setServiceProviderId(configuration.kitId) kitManager.onResult(result) } override fun onConversionDataFail(conversionFailure: String) { if (!KitUtils.isEmpty(conversionFailure)) { - val error = AttributionError() - .setMessage(conversionFailure) - .setServiceProviderId(configuration.kitId) + val error = + AttributionError() + .setMessage(conversionFailure) + .setServiceProviderId(configuration.kitId) kitManager.onError(error) } } - - fun deepLinkListener() = DeepLinkListener { deepLinkResult -> - val deepLinkObj = deepLinkResult.deepLink - - when (deepLinkResult.status) { - DeepLinkResult.Status.FOUND -> { - try { - deepLinkObj.clickEvent.put(APP_OPEN_ATTRIBUTION_RESULT, true.toString()) - val result = AttributionResult() - .setParameters(deepLinkObj.clickEvent) - .setServiceProviderId(configuration.kitId) - kitManager.onResult(result) - } catch (e: Exception) { + fun deepLinkListener() = + DeepLinkListener { deepLinkResult -> + val deepLinkObj = deepLinkResult.deepLink + + when (deepLinkResult.status) { + DeepLinkResult.Status.FOUND -> { + try { + deepLinkObj.clickEvent.put(APP_OPEN_ATTRIBUTION_RESULT, true.toString()) + val result = + AttributionResult() + .setParameters(deepLinkObj.clickEvent) + .setServiceProviderId(configuration.kitId) + kitManager.onResult(result) + } catch (e: Exception) { + return@DeepLinkListener + } + } + DeepLinkResult.Status.NOT_FOUND -> { return@DeepLinkListener } - } - DeepLinkResult.Status.NOT_FOUND -> { - return@DeepLinkListener - } - else -> { - val dlError = deepLinkResult.error - if (!KitUtils.isEmpty(dlError.toString())) { - val error = AttributionError() - .setMessage(dlError.toString()) - .setServiceProviderId(configuration.kitId) - kitManager.onError(error) + else -> { + val dlError = deepLinkResult.error + if (!KitUtils.isEmpty(dlError.toString())) { + val error = + AttributionError() + .setMessage(dlError.toString()) + .setServiceProviderId(configuration.kitId) + kitManager.onError(error) + } + return@DeepLinkListener } - return@DeepLinkListener } } - } - override fun onAppOpenAttribution(attributionDataN: MutableMap?) { - //do nothing, Appsflyer new UDL implementation will use new deep linking method with both + // do nothing, Appsflyer new UDL implementation will use new deep linking method with both // custom URI and appsflyer's Onelink } override fun onAttributionFailure(attributionFailure: String) { - //do nothing, Appsflyer new UDL implementation will use new deep linking method with both + // do nothing, Appsflyer new UDL implementation will use new deep linking method with both // custom URI and appsflyer's Onelink } override fun setInstallReferrer(intent: Intent) { - //do nothing, Appsflyer will fetch the install referrer data internally, + // do nothing, Appsflyer will fetch the install referrer data internally, // as long as the proper Play Install Referrer dependency is present. } @@ -514,7 +554,7 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, override fun onActivityCreated( activity: Activity, - bundle: Bundle? + bundle: Bundle?, ): List { instance.start(activity) return emptyList() @@ -530,12 +570,11 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, override fun onActivitySaveInstanceState( activity: Activity, - bundle: Bundle? + bundle: Bundle?, ): List = emptyList() override fun onActivityDestroyed(activity: Activity): List = emptyList() - companion object { const val DEV_KEY = "devKey" const val APPSFLYERID_INTEGRATION_KEY = "appsflyer_id_integration_setting" @@ -553,23 +592,28 @@ class AppsFlyerKit : KitIntegration(), KitIntegration.EventListener, const val APP_OPEN_ATTRIBUTION_RESULT = "MPARTICLE_APPSFLYER_APP_OPEN_ATTRIBUTION_RESULT" - fun generateProductIdList(event: CommerceEvent?): List? { - return event?.products?.filter { !KitUtils.isEmpty(it.sku) }?.let { + fun generateProductIdList(event: CommerceEvent?): List? = + event?.products?.filter { !KitUtils.isEmpty(it.sku) }?.let { if (it.isNotEmpty()) { it.map { it.sku.replace(COMMA, "%2C") } - } else { null } + } else { + null + } } - } - private const val consentMapping = "consentMapping" - enum class AppsFlyerConsentValues(val consentValue: String) { + private const val CONSENT_MAPPING = "consentMapping" + + @Suppress("ktlint:standard:property-naming") + enum class AppsFlyerConsentValues( + val consentValue: String, + ) { GRANTED("Granted"), - DENIED("Denied") + DENIED("Denied"), } - val GDPR_APPLIES = "gdprApplies" - val DEFAULT_AD_STORAGE_CONSENT = "defaultAdStorageConsent" - val DEFAULT_AD_USER_DATA_CONSENT = "defaultAdUserDataConsent" - val DEFAULT_AD_PERSONALIZATION_CONSENT = "defaultAdPersonalizationConsent" + const val GDPR_APPLIES = "gdprApplies" + const val DEFAULT_AD_STORAGE_CONSENT = "defaultAdStorageConsent" + const val DEFAULT_AD_USER_DATA_CONSENT = "defaultAdUserDataConsent" + const val DEFAULT_AD_PERSONALIZATION_CONSENT = "defaultAdPersonalizationConsent" } } diff --git a/src/test/kotlin/com/appsflyer/AppsFlyerConsent.kt b/src/test/kotlin/com/appsflyer/AppsFlyerConsent.kt index c368b5c..eb5cf5e 100644 --- a/src/test/kotlin/com/appsflyer/AppsFlyerConsent.kt +++ b/src/test/kotlin/com/appsflyer/AppsFlyerConsent.kt @@ -4,7 +4,5 @@ class AppsFlyerConsent( val isUserSubjectToGDPR: Boolean?, val hasConsentForDataUsage: Boolean?, val hasConsentForAdsPersonalization: Boolean?, - val hasConsentForAdStorage: Boolean? -) { - -} + val hasConsentForAdStorage: Boolean?, +) diff --git a/src/test/kotlin/com/appsflyer/AppsFlyerLib.kt b/src/test/kotlin/com/appsflyer/AppsFlyerLib.kt index 8406e93..0ce8e82 100644 --- a/src/test/kotlin/com/appsflyer/AppsFlyerLib.kt +++ b/src/test/kotlin/com/appsflyer/AppsFlyerLib.kt @@ -9,9 +9,7 @@ class AppsFlyerLib { consentData = consent } - fun getConsentData(): AppsFlyerConsent? { - return consentData - } + fun getConsentData(): AppsFlyerConsent? = consentData fun getConsentState(): MutableMap { val stateMap = mutableMapOf() @@ -37,9 +35,7 @@ class AppsFlyerLib { } @JvmStatic - fun getInstance(context: Context?): AppsFlyerLib? { - return getInstance() - } + fun getInstance(context: Context?): AppsFlyerLib? = getInstance() /** * Access Methods diff --git a/src/test/kotlin/com/mparticle/kits/AppsflyerKitTests.kt b/src/test/kotlin/com/mparticle/kits/AppsflyerKitTests.kt index 9b1353d..6c7201f 100644 --- a/src/test/kotlin/com/mparticle/kits/AppsflyerKitTests.kt +++ b/src/test/kotlin/com/mparticle/kits/AppsflyerKitTests.kt @@ -3,12 +3,12 @@ package com.mparticle.kits import android.app.Activity import android.content.Context import android.net.Uri +import com.appsflyer.AppsFlyerLib import com.mparticle.MParticle import com.mparticle.MParticleOptions import com.mparticle.commerce.CommerceEvent import com.mparticle.commerce.Product import com.mparticle.commerce.TransactionAttributes -import com.appsflyer.AppsFlyerLib import com.mparticle.consent.ConsentState import com.mparticle.consent.GDPRConsent import com.mparticle.identity.IdentityApi @@ -30,9 +30,7 @@ import org.mockito.MockitoAnnotations import java.lang.ref.WeakReference import java.lang.reflect.Method - class AppsflyerKitTests { - private var kit = AppsFlyerKit() private var appsflyer = AppsFlyerLib() @@ -49,16 +47,22 @@ class AppsflyerKitTests { kit = AppsFlyerKit() MockitoAnnotations.initMocks(this) MParticle.setInstance(mock(MParticle::class.java)) - Mockito.`when`(MParticle.getInstance()?.Identity()).thenReturn( - mock( - IdentityApi::class.java + Mockito + .`when`(MParticle.getInstance()?.Identity()) + .thenReturn( + mock( + IdentityApi::class.java, + ), + ) + val kitManager = + KitManagerImpl( + mock( + Context::class.java, + ), + null, + emptyCoreCallbacks, + mock(MParticleOptions::class.java), ) - ) - val kitManager = KitManagerImpl( - mock( - Context::class.java - ), null, emptyCoreCallbacks, mock(MParticleOptions::class.java) - ) kit.kitManager = kitManager kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("id", "-1")) @@ -109,31 +113,39 @@ class AppsflyerKitTests { @Throws(Exception::class) fun testGenerateSkuString() { MParticle.setInstance(mock(MParticle::class.java)) - Mockito.`when`(MParticle.getInstance()?.environment) + Mockito + .`when`(MParticle.getInstance()?.environment) .thenReturn(MParticle.Environment.Production) Assert.assertNull(AppsFlyerKit.generateProductIdList(null)) val product = Product.Builder("foo-name", "foo-sku", 50.0).build() - val event = CommerceEvent.Builder(Product.PURCHASE, product) - .transactionAttributes(TransactionAttributes("foo")) - .build() + val event = + CommerceEvent + .Builder(Product.PURCHASE, product) + .transactionAttributes(TransactionAttributes("foo")) + .build() assertEquals(mutableListOf("foo-sku"), AppsFlyerKit.generateProductIdList(event)) val product2 = Product.Builder("foo-name-2", "foo-sku-2", 50.0).build() - val event2 = CommerceEvent.Builder(Product.PURCHASE, product) - .addProduct(product2) - .transactionAttributes(TransactionAttributes("foo")) - .build() + val event2 = + CommerceEvent + .Builder(Product.PURCHASE, product) + .addProduct(product2) + .transactionAttributes(TransactionAttributes("foo")) + .build() assertEquals( - mutableListOf("foo-sku", "foo-sku-2"), AppsFlyerKit.generateProductIdList(event2) + mutableListOf("foo-sku", "foo-sku-2"), + AppsFlyerKit.generateProductIdList(event2), ) val product3 = Product.Builder("foo-name-3", "foo-sku-,3", 50.0).build() - val event3 = CommerceEvent.Builder(Product.PURCHASE, product) - .addProduct(product2) - .addProduct(product3) - .transactionAttributes(TransactionAttributes("foo")) - .build() + val event3 = + CommerceEvent + .Builder(Product.PURCHASE, product) + .addProduct(product2) + .addProduct(product3) + .transactionAttributes(TransactionAttributes("foo")) + .build() assertEquals( mutableListOf("foo-sku", "foo-sku-2", "foo-sku-%2C3"), - AppsFlyerKit.generateProductIdList(event3) + AppsFlyerKit.generateProductIdList(event3), ) } @@ -151,31 +163,38 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - - val marketingConsent = GDPRConsent.builder(false) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val state = ConsentState.builder() - .addGDPRConsentState("Marketing", marketingConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(false) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val state = + ConsentState + .builder() + .addGDPRConsentState("Marketing", marketingConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(false, expectedConsentValue) - val notExpectedConsentKey = afConsentResults.containsKey("hasConsentForDataUsage") + val notExpectedConsentKey = + afConsentResults.containsKey("hasConsentForDataUsage") TestCase.assertEquals(false, notExpectedConsentKey) - val notExpectedConsentKey2 = afConsentResults.containsKey("hasConsentForAdsPersonalization") + val notExpectedConsentKey2 = + afConsentResults.containsKey("hasConsentForAdsPersonalization") TestCase.assertEquals(false, notExpectedConsentKey2) - val notExpectedConsentKey3 = afConsentResults.containsKey("hasConsentForAdStorage") + val notExpectedConsentKey3 = + afConsentResults.containsKey("hasConsentForAdStorage") TestCase.assertEquals(false, notExpectedConsentKey3) } @@ -193,31 +212,38 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - - val marketingConsent = GDPRConsent.builder(false) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val state = ConsentState.builder() - .addGDPRConsentState("test1", marketingConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(false) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val state = + ConsentState + .builder() + .addGDPRConsentState("test1", marketingConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(true, expectedConsentValue) - val notExpectedConsentKey = afConsentResults.containsKey("hasConsentForDataUsage") + val notExpectedConsentKey = + afConsentResults.containsKey("hasConsentForDataUsage") TestCase.assertEquals(false, notExpectedConsentKey) - val notExpectedConsentKey2 = afConsentResults.containsKey("hasConsentForAdsPersonalization") + val notExpectedConsentKey2 = + afConsentResults.containsKey("hasConsentForAdsPersonalization") TestCase.assertEquals(false, notExpectedConsentKey2) - val notExpectedConsentKey3 = afConsentResults.containsKey("hasConsentForAdStorage") + val notExpectedConsentKey3 = + afConsentResults.containsKey("hasConsentForAdStorage") TestCase.assertEquals(false, notExpectedConsentKey3) } @@ -235,34 +261,41 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - - val marketingConsent = GDPRConsent.builder(false) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val state = ConsentState.builder() - .addGDPRConsentState("test1", marketingConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(false) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val state = + ConsentState + .builder() + .addGDPRConsentState("test1", marketingConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(true, expectedConsentValue) val expectedConsentValue2 = - afConsentResults.getValue("hasConsentForDataUsage") + afConsentResults + .getValue("hasConsentForDataUsage") TestCase.assertEquals(false, expectedConsentValue2) val expectedConsentValue3 = - afConsentResults.getValue("hasConsentForAdsPersonalization") + afConsentResults + .getValue("hasConsentForAdsPersonalization") TestCase.assertEquals(true, expectedConsentValue3) val expectedConsentValue4 = - afConsentResults.getValue("hasConsentForAdStorage") + afConsentResults + .getValue("hasConsentForAdStorage") TestCase.assertEquals(true, expectedConsentValue4) } @@ -280,46 +313,57 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - - val performanceConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val marketingConsent = GDPRConsent.builder(false) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val testConsent = GDPRConsent.builder(false) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val state = ConsentState.builder() - .addGDPRConsentState("Performance", performanceConsent) - .addGDPRConsentState("Marketing", marketingConsent) - .addGDPRConsentState("testconsent", testConsent) - .build() + val performanceConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val marketingConsent = + GDPRConsent + .builder(false) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val testConsent = + GDPRConsent + .builder(false) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val state = + ConsentState + .builder() + .addGDPRConsentState("Performance", performanceConsent) + .addGDPRConsentState("Marketing", marketingConsent) + .addGDPRConsentState("testconsent", testConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(true, expectedConsentValue) val expectedConsentValue2 = - afConsentResults.getValue("hasConsentForDataUsage") + afConsentResults + .getValue("hasConsentForDataUsage") TestCase.assertEquals(true, expectedConsentValue2) val expectedConsentValue3 = - afConsentResults.getValue("hasConsentForAdsPersonalization") + afConsentResults + .getValue("hasConsentForAdsPersonalization") TestCase.assertEquals(false, expectedConsentValue3) val expectedConsentValue4 = - afConsentResults.getValue("hasConsentForAdStorage") + afConsentResults + .getValue("hasConsentForAdStorage") TestCase.assertEquals(false, expectedConsentValue4) } @@ -336,42 +380,51 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - - val performanceConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val marketingConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val state = ConsentState.builder() - .addGDPRConsentState("Performance", performanceConsent) - .addGDPRConsentState("Marketing", marketingConsent) - .build() + val performanceConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val marketingConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val state = + ConsentState + .builder() + .addGDPRConsentState("Performance", performanceConsent) + .addGDPRConsentState("Marketing", marketingConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(true, expectedConsentValue) val expectedConsentValue2 = - afConsentResults.getValue("hasConsentForDataUsage") + afConsentResults + .getValue("hasConsentForDataUsage") TestCase.assertEquals(true, expectedConsentValue2) val expectedConsentValue3 = - afConsentResults.getValue("hasConsentForAdsPersonalization") + afConsentResults + .getValue("hasConsentForAdsPersonalization") TestCase.assertEquals(true, expectedConsentValue3) val expectedConsentValue4 = - afConsentResults.getValue("hasConsentForAdStorage") + afConsentResults + .getValue("hasConsentForAdStorage") TestCase.assertEquals(true, expectedConsentValue4) } @@ -382,40 +435,48 @@ class AppsflyerKitTests { map["consentMapping"] = "[{\\\"jsmap\\\":null,\\\"map\\\":\\\"Performance\\\",\\\"maptype\\\":\\\"ConsentPurposes\\\",\\\"value\\\":\\\"ad_user_data\\\"},{\\\"jsmap\\\":null,\\\"map\\\":\\\"Marketing\\\",\\\"maptype\\\":\\\"ConsentPurposes\\\",\\\"value\\\":\\\"ad_personalization\\\"},{\\\"jsmap\\\":null,\\\"map\\\":\\\"testconsent\\\",\\\"maptype\\\":\\\"ConsentPurposes\\\",\\\"value\\\":\\\"ad_storage\\\"}]" - kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - val marketingConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val performanceConsent = GDPRConsent.builder(true) - .document("parental_consent_agreement_v2") - .location("17 Cherry Tree Lan 3") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val state = ConsentState.builder() - .addGDPRConsentState("Marketing", marketingConsent) - .addGDPRConsentState("Performance", performanceConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val performanceConsent = + GDPRConsent + .builder(true) + .document("parental_consent_agreement_v2") + .location("17 Cherry Tree Lan 3") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val state = + ConsentState + .builder() + .addGDPRConsentState("Marketing", marketingConsent) + .addGDPRConsentState("Performance", performanceConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(true, expectedConsentValue) val expectedConsentValue2 = - afConsentResults.getValue("hasConsentForDataUsage") + afConsentResults + .getValue("hasConsentForDataUsage") TestCase.assertEquals(true, expectedConsentValue2) val expectedConsentValue3 = - afConsentResults.getValue("hasConsentForAdsPersonalization") + afConsentResults + .getValue("hasConsentForAdsPersonalization") TestCase.assertEquals(true, expectedConsentValue3) val notExpectedConsentKey = @@ -425,23 +486,28 @@ class AppsflyerKitTests { @Test fun onConsentStateUpdatedTest_When_No_DATA_From_Server() { - - val marketingConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val performanceConsent = GDPRConsent.builder(true) - .document("parental_consent_agreement_v2") - .location("17 Cherry Tree Lan 3") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val state = ConsentState.builder() - .addGDPRConsentState("Marketing", marketingConsent) - .addGDPRConsentState("Performance", performanceConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val performanceConsent = + GDPRConsent + .builder(true) + .document("parental_consent_agreement_v2") + .location("17 Cherry Tree Lan 3") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val state = + ConsentState + .builder() + .addGDPRConsentState("Marketing", marketingConsent) + .addGDPRConsentState("Performance", performanceConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) @@ -460,43 +526,52 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - val marketingConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val performanceConsent = GDPRConsent.builder(true) - .document("parental_consent_agreement_v2") - .location("17 Cherry Tree Lan 3") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val state = ConsentState.builder() - .addGDPRConsentState("Marketing", marketingConsent) - .addGDPRConsentState("Performance", performanceConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val performanceConsent = + GDPRConsent + .builder(true) + .document("parental_consent_agreement_v2") + .location("17 Cherry Tree Lan 3") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val state = + ConsentState + .builder() + .addGDPRConsentState("Marketing", marketingConsent) + .addGDPRConsentState("Performance", performanceConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(true, expectedConsentValue) val expectedConsentValue2 = - afConsentResults.getValue("hasConsentForDataUsage") + afConsentResults + .getValue("hasConsentForDataUsage") TestCase.assertEquals(false, expectedConsentValue2) val expectedConsentValue3 = - afConsentResults.getValue("hasConsentForAdsPersonalization") + afConsentResults + .getValue("hasConsentForAdsPersonalization") TestCase.assertEquals(false, expectedConsentValue3) val expectedConsentValue4 = - afConsentResults.getValue("hasConsentForAdStorage") + afConsentResults + .getValue("hasConsentForAdStorage") TestCase.assertEquals(true, expectedConsentValue4) - } @Test @@ -510,21 +585,27 @@ class AppsflyerKitTests { kit.configuration = KitConfiguration.createKitConfiguration(JSONObject().put("as", map.toMutableMap())) - val marketingConsent = GDPRConsent.builder(true) - .document("Test consent") - .location("17 Cherry Tree Lane") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - - val performanceConsent = GDPRConsent.builder(true) - .document("parental_consent_agreement_v2") - .location("17 Cherry Tree Lan 3") - .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") - .build() - val state = ConsentState.builder() - .addGDPRConsentState("Marketing", marketingConsent) - .addGDPRConsentState("Performance", performanceConsent) - .build() + val marketingConsent = + GDPRConsent + .builder(true) + .document("Test consent") + .location("17 Cherry Tree Lane") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + + val performanceConsent = + GDPRConsent + .builder(true) + .document("parental_consent_agreement_v2") + .location("17 Cherry Tree Lan 3") + .hardwareId("IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702") + .build() + val state = + ConsentState + .builder() + .addGDPRConsentState("Marketing", marketingConsent) + .addGDPRConsentState("Performance", performanceConsent) + .build() filteredMParticleUser = FilteredMParticleUser.getInstance(user, kit) kit.onConsentStateUpdated(state, state, filteredMParticleUser) @@ -532,7 +613,8 @@ class AppsflyerKitTests { TestCase.assertEquals(1, appsflyer.getConsentState().size) val afConsentResults = appsflyer.getConsentState() val expectedConsentValue = - afConsentResults.getValue("isUserSubjectToGDPR") + afConsentResults + .getValue("isUserSubjectToGDPR") TestCase.assertEquals(false, expectedConsentValue) } @@ -541,10 +623,11 @@ class AppsflyerKitTests { var jsonInput = "{'GDPR':{'marketing':'{:false,'timestamp':1711038269644:'Test consent','location':'17 Cherry Tree Lane','hardware_id':'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'}','performance':'{'consented':true,'timestamp':1711038269644,'document':'parental_consent_agreement_v2','location':'17 Cherry Tree Lan 3','hardware_id':'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'}'},'CCPA':'{'consented':true,'timestamp':1711038269644,'document':'ccpa_consent_agreement_v3','location':'17 Cherry Tree Lane','hardware_id':'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'}'}" - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "parseToNestedMap", - String::class.java - ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "parseToNestedMap", + String::class.java, + ) method.isAccessible = true val result = method.invoke(kit, jsonInput) Assert.assertEquals(mutableMapOf(), result) @@ -554,10 +637,11 @@ class AppsflyerKitTests { fun testParseToNestedMap_When_JSON_Is_Empty() { var jsonInput = "" - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "parseToNestedMap", - String::class.java - ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "parseToNestedMap", + String::class.java, + ) method.isAccessible = true val result = method.invoke(kit, jsonInput) Assert.assertEquals(mutableMapOf(), result) @@ -565,19 +649,24 @@ class AppsflyerKitTests { @Test fun testSearchKeyInNestedMap_When_Input_Key_Is_Empty_String() { - val map = mapOf( - "GDPR" to true, - "marketing" to mapOf( - "consented" to false, - "document" to mapOf( - "timestamp" to 1711038269644 - ) + val map = + mapOf( + "GDPR" to true, + "marketing" to + mapOf( + "consented" to false, + "document" to + mapOf( + "timestamp" to 1711038269644, + ), + ), + ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "searchKeyInNestedMap", + Map::class.java, + Any::class.java, ) - ) - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "searchKeyInNestedMap", Map::class.java, - Any::class.java - ) method.isAccessible = true val result = method.invoke(kit, map, "") Assert.assertEquals(null, result) @@ -586,10 +675,12 @@ class AppsflyerKitTests { @Test fun testSearchKeyInNestedMap_When_Input_Is_Empty_Map() { val emptyMap: Map = emptyMap() - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "searchKeyInNestedMap", Map::class.java, - Any::class.java - ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "searchKeyInNestedMap", + Map::class.java, + Any::class.java, + ) method.isAccessible = true val result = method.invoke(kit, emptyMap, "1") Assert.assertEquals(null, result) @@ -598,10 +689,11 @@ class AppsflyerKitTests { @Test fun testParseConsentMapping_When_Input_Is_Empty_Json() { val emptyJson = "" - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "parseConsentMapping", - String::class.java - ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "parseConsentMapping", + String::class.java, + ) method.isAccessible = true val result = method.invoke(kit, emptyJson) Assert.assertEquals(emptyMap(), result) @@ -611,10 +703,11 @@ class AppsflyerKitTests { fun testParseConsentMapping_When_Input_Is_Invalid_Json() { var jsonInput = "{'GDPR':{'marketing':'{:false,'timestamp':1711038269644:'Test consent','location':'17 Cherry Tree Lane','hardware_id':'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'}','performance':'{'consented':true,'timestamp':1711038269644,'document':'parental_consent_agreement_v2','location':'17 Cherry Tree Lan 3','hardware_id':'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'}'},'CCPA':'{'consented':true,'timestamp':1711038269644,'document':'ccpa_consent_agreement_v3','location':'17 Cherry Tree Lane','hardware_id':'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'}'}" - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "parseConsentMapping", - String::class.java - ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "parseConsentMapping", + String::class.java, + ) method.isAccessible = true val result = method.invoke(kit, jsonInput) Assert.assertEquals(emptyMap(), result) @@ -622,59 +715,78 @@ class AppsflyerKitTests { @Test fun testParseConsentMapping_When_Input_Is_NULL() { - val method: Method = AppsFlyerKit::class.java.getDeclaredMethod( - "parseConsentMapping", - String::class.java - ) + val method: Method = + AppsFlyerKit::class.java.getDeclaredMethod( + "parseConsentMapping", + String::class.java, + ) method.isAccessible = true val result = method.invoke(kit, null) Assert.assertEquals(emptyMap(), result) } - private var emptyCoreCallbacks: CoreCallbacks = object : CoreCallbacks { - var activity = Activity() - override fun isBackgrounded(): Boolean = false + private var emptyCoreCallbacks: CoreCallbacks = + object : CoreCallbacks { + var activity = Activity() + + override fun isBackgrounded(): Boolean = false + + override fun getUserBucket(): Int = 0 + + override fun isEnabled(): Boolean = false + + override fun setIntegrationAttributes( + i: Int, + map: Map, + ) {} - override fun getUserBucket(): Int = 0 + override fun getIntegrationAttributes(i: Int): Map? = null - override fun isEnabled(): Boolean = false + override fun getCurrentActivity(): WeakReference = WeakReference(activity) - override fun setIntegrationAttributes(i: Int, map: Map) {} + override fun getLatestKitConfiguration(): JSONArray? = null - override fun getIntegrationAttributes(i: Int): Map? = null + override fun getDataplanOptions(): MParticleOptions.DataplanOptions? = null - override fun getCurrentActivity(): WeakReference = WeakReference(activity) + override fun isPushEnabled(): Boolean = false - override fun getLatestKitConfiguration(): JSONArray? = null + override fun getPushSenderId(): String? = null - override fun getDataplanOptions(): MParticleOptions.DataplanOptions? = null + override fun getPushInstanceId(): String? = null - override fun isPushEnabled(): Boolean = false + override fun getLaunchUri(): Uri? = null - override fun getPushSenderId(): String? = null + override fun getLaunchAction(): String? = null - override fun getPushInstanceId(): String? = null + override fun getKitListener(): KitListener = + object : KitListener { + override fun kitFound(kitId: Int) {} - override fun getLaunchUri(): Uri? = null + override fun kitConfigReceived( + kitId: Int, + configuration: String?, + ) {} - override fun getLaunchAction(): String? = null + override fun kitExcluded( + kitId: Int, + reason: String?, + ) {} - override fun getKitListener(): KitListener { - return object : KitListener { - override fun kitFound(kitId: Int) {} - override fun kitConfigReceived(kitId: Int, configuration: String?) {} - override fun kitExcluded(kitId: Int, reason: String?) {} - override fun kitStarted(kitId: Int) {} - override fun onKitApiCalled(kitId: Int, used: Boolean?, vararg objects: Any?) {} - override fun onKitApiCalled( - methodName: String?, - kitId: Int, - used: Boolean?, - vararg objects: Any? - ) { + override fun kitStarted(kitId: Int) {} + + override fun onKitApiCalled( + kitId: Int, + used: Boolean?, + vararg objects: Any?, + ) {} + + override fun onKitApiCalled( + methodName: String?, + kitId: Int, + used: Boolean?, + vararg objects: Any?, + ) { + } } - } } - - } -} \ No newline at end of file +}