diff --git a/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt b/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt index 32013b0e..489c2520 100644 --- a/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt +++ b/emarsys-sdk/src/main/java/com/emarsys/di/DefaultEmarsysComponent.kt @@ -516,7 +516,6 @@ open class DefaultEmarsysComponent(config: EmarsysConfig) : EmarsysComponent { config.applicationCode, null, null, - null, deviceInfo, timestampProvider, uuidProvider, @@ -524,6 +523,7 @@ open class DefaultEmarsysComponent(config: EmarsysConfig) : EmarsysComponent { contactTokenStorage, refreshTokenStorage, pushTokenStorage, + contactFieldValueStorage, sessionIdHolder ) } diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/DefaultMobileEngageInternalTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/DefaultMobileEngageInternalTest.kt index 024e8e47..56ac3ab4 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/DefaultMobileEngageInternalTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/DefaultMobileEngageInternalTest.kt @@ -184,6 +184,7 @@ class DefaultMobileEngageInternalTest : AnnotationSpec() { ) verifyNoInteractions(mockRequestManager) + verify(mockCompletionListener).onCompleted(null) } @Test diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/MobileEngageRequestContextTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/MobileEngageRequestContextTest.kt index c8dc7241..f37885da 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/MobileEngageRequestContextTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/MobileEngageRequestContextTest.kt @@ -1,21 +1,25 @@ package com.emarsys.mobileengage +import com.emarsys.core.storage.Storage import com.emarsys.testUtil.AnnotationSpec import io.kotest.matchers.shouldBe import org.mockito.kotlin.mock +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever class MobileEngageRequestContextTest : AnnotationSpec() { + private lateinit var mockContactFieldValueStorage: Storage + private lateinit var requestContext: MobileEngageRequestContext @Before fun setUp() { - + mockContactFieldValueStorage = mock>() requestContext = MobileEngageRequestContext( "appCode", 1, null, - null, mock(), mock(), mock(), @@ -23,6 +27,7 @@ class MobileEngageRequestContextTest : AnnotationSpec() { mock(), mock(), mock(), + mockContactFieldValueStorage, mock() ) } @@ -52,10 +57,28 @@ class MobileEngageRequestContextTest : AnnotationSpec() { @Test fun testHasContactIdentification_whenHasContactFieldValue_shouldBeTrue() { - requestContext.contactFieldValue = "contactFieldValue" + whenever(mockContactFieldValueStorage.get()).thenReturn("contactFieldValue") requestContext.openIdToken = null requestContext.hasContactIdentification() shouldBe true } + + @Test + fun testContactFieldValue_setter_shouldDelegateToStorage() { + val testContactFieldValue = "testContactFieldValue" + + requestContext.contactFieldValue = "testContactFieldValue" + + verify(mockContactFieldValueStorage).set(testContactFieldValue) + } + + @Test + fun testContactFieldValue_getter_shouldDelegateToStorage() { + val testContactFieldValue = "testContactFieldValue" + whenever(mockContactFieldValueStorage.get()).thenReturn(testContactFieldValue) + + requestContext.contactFieldValue shouldBe testContactFieldValue + verify(mockContactFieldValueStorage).get() + } } \ No newline at end of file diff --git a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/deeplink/DefaultDeepLinkInternalTest.kt b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/deeplink/DefaultDeepLinkInternalTest.kt index f2057aa5..6fa38b16 100644 --- a/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/deeplink/DefaultDeepLinkInternalTest.kt +++ b/mobile-engage/src/androidTest/java/com/emarsys/mobileengage/deeplink/DefaultDeepLinkInternalTest.kt @@ -49,13 +49,14 @@ class DefaultDeepLinkInternalTest : AnnotationSpec() { APPLICATION_CODE, 1, null, - null, mockDeviceInfo, + mockDeviceInfo, mockTimestampProvider, mockUuidProvider, mock(StringStorage::class.java), mock(StringStorage::class.java), mock(StringStorage::class.java), mock(StringStorage::class.java), + mock(StringStorage::class.java), mock(SessionIdHolder::class.java) ) mockDeepLinkServiceProvider = Mockito.mock(ServiceEndpointProvider::class.java) diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/DefaultMobileEngageInternal.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/DefaultMobileEngageInternal.kt index 3ae0064c..a549b079 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/DefaultMobileEngageInternal.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/DefaultMobileEngageInternal.kt @@ -39,6 +39,8 @@ class DefaultMobileEngageInternal( Logger.error(CrashLog(it)) } } + } else { + completionListener?.onCompleted(null) } } diff --git a/mobile-engage/src/main/java/com/emarsys/mobileengage/MobileEngageRequestContext.kt b/mobile-engage/src/main/java/com/emarsys/mobileengage/MobileEngageRequestContext.kt index d10c6131..7bed20b4 100644 --- a/mobile-engage/src/main/java/com/emarsys/mobileengage/MobileEngageRequestContext.kt +++ b/mobile-engage/src/main/java/com/emarsys/mobileengage/MobileEngageRequestContext.kt @@ -11,7 +11,6 @@ import com.emarsys.mobileengage.session.SessionIdHolder data class MobileEngageRequestContext( var applicationCode: String?, var contactFieldId: Int?, - var contactFieldValue: String?, var openIdToken: String? = null, val deviceInfo: DeviceInfo, val timestampProvider: TimestampProvider, @@ -20,9 +19,19 @@ data class MobileEngageRequestContext( val contactTokenStorage: Storage, val refreshTokenStorage: Storage, val pushTokenStorage: Storage, + val contactFieldValueStorage: Storage, val sessionIdHolder: SessionIdHolder ) { + var contactFieldValue: String? + get() { + return contactFieldValueStorage.get() + } + set(value) { + contactFieldValueStorage.set(value) + } + + fun hasContactIdentification(): Boolean { return openIdToken != null || contactFieldValue != null }