From f26005842900e4da3e33f89ccc110ffcba429288 Mon Sep 17 00:00:00 2001 From: Arjun Bhadra Date: Fri, 13 May 2022 14:43:08 -0700 Subject: [PATCH 1/4] [MOB-15817] Add getUrlVariables public API (#59) * [MOB-15817] Implemented getUrlVariables public API * [MOB-15817] Added unit tests for getUrlVariable implementation logic * [MOB-15817] Updated sample app with getUrlVariable public API * [MOB-1917] Clear config * [MOB-15817] Format fixes * [MOB-15817] Fix javadoc * [MOB-15817] minor bug fix and test fixes * [MOB-15817] Add more tests * [MOB-15817] Add tests, make minor fixes and review fixes * [MOB-15817] Fix test and added a test to improve coverage * [MOB-15817] Minor refactoring based on reviews * [MOB-15817] More tests, minor refactoring and review fixes * [MOB-15817] Review fixes * [MOB-15817] Fix method java doc description * [MOB-15817] Used java.net.URLEncoder instead of custom implementation. Added few tests. Also added review fixes. * [MOB-15817] Added more tests for URL encoder * [MOB-15817] Cleanup urlEncode helper and tests --- .../identity/app/model/SharedViewModel.kt | 7 + .../identity/app/ui/GetIdentityFragment.kt | 23 ++ .../main/res/layout/fragment_get_identity.xml | 25 ++ code/app/src/main/res/values/strings.xml | 1 + .../identity/IdentityFunctionalTestUtil.java | 13 ++ .../edge/identity/IdentityPublicAPITest.java | 24 ++ .../mobile/edge/identity/EventUtils.java | 57 +++++ .../mobile/edge/identity/Identity.java | 87 +++++++ .../edge/identity/IdentityConstants.java | 27 +++ .../edge/identity/IdentityExtension.java | 105 ++++++++- .../edge/identity/IdentityProperties.java | 2 +- .../mobile/edge/identity/URLUtils.java | 92 ++++++++ .../marketing/mobile/edge/identity/Utils.java | 13 +- .../edge/identity/IdentityTestUtil.java | 20 ++ .../mobile/edge/identity/EventUtilsTests.java | 168 ++++++++++++++ .../edge/identity/IdentityExtensionTests.java | 219 ++++++++++++++++++ .../edge/identity/IdentityStateTests.java | 12 + .../mobile/edge/identity/IdentityTests.java | 195 ++++++++++++++++ ...tenerEdgeIdentityRequestIdentityTests.java | 27 +++ .../mobile/edge/identity/URLUtilsTests.java | 37 +++ 20 files changed, 1150 insertions(+), 4 deletions(-) create mode 100644 code/edgeidentity/src/main/java/com/adobe/marketing/mobile/edge/identity/URLUtils.java create mode 100644 code/edgeidentity/src/test/java/com/adobe/marketing/mobile/edge/identity/EventUtilsTests.java create mode 100644 code/edgeidentity/src/test/java/com/adobe/marketing/mobile/edge/identity/URLUtilsTests.java diff --git a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt index 77cac6d4..223c89ba 100644 --- a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt +++ b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/model/SharedViewModel.kt @@ -32,6 +32,9 @@ class SharedViewModel : ViewModel() { private val _ecidLegacyText = MutableLiveData("") val ecidLegacyText: LiveData = _ecidLegacyText + private val _urlVariablesText = MutableLiveData("") + val urlVariablesText: LiveData = _urlVariablesText + private val _identitiesText = MutableLiveData("") val identitiesText: LiveData = _identitiesText @@ -43,6 +46,10 @@ class SharedViewModel : ViewModel() { _ecidLegacyText.value = value } + fun setUrlVariablesValue(value: String) { + _urlVariablesText.value = value + } + fun setIdentitiesValue(value: String) { _identitiesText.value = value } diff --git a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/GetIdentityFragment.kt b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/GetIdentityFragment.kt index 7198f7f0..90ff01f3 100644 --- a/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/GetIdentityFragment.kt +++ b/code/app/src/main/java/com/adobe/marketing/edge/identity/app/ui/GetIdentityFragment.kt @@ -54,6 +54,14 @@ class GetIdentityFragment : Fragment() { } ) + val urlVariablesTextView = root.findViewById(R.id.text_url_variables) + sharedViewModel.urlVariablesText.observe( + viewLifecycleOwner, + Observer { + urlVariablesTextView.text = it + } + ) + val identitiesTextView = root.findViewById(R.id.text_identities) sharedViewModel.identitiesText.observe( viewLifecycleOwner, @@ -85,6 +93,21 @@ class GetIdentityFragment : Fragment() { sharedViewModel.setEcidLegacyValue(if (resultSecondary != null) "legacy: $resultSecondary" else "") } + root.findViewById