Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into SUITEDEV-35599-MultiID-for-predict
Browse files Browse the repository at this point in the history
  • Loading branch information
matusekma committed Oct 4, 2024
2 parents f3bb2d7 + 6f8a878 commit 689e819
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,14 @@ open class DefaultEmarsysComponent(config: EmarsysConfig) : EmarsysComponent {
config.applicationCode,
null,
null,
null,
deviceInfo,
timestampProvider,
uuidProvider,
clientStateStorage,
contactTokenStorage,
refreshTokenStorage,
pushTokenStorage,
contactFieldValueStorage,
sessionIdHolder
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class DefaultMobileEngageInternalTest : AnnotationSpec() {
)

verifyNoInteractions(mockRequestManager)
verify(mockCompletionListener).onCompleted(null)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
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<String?>

private lateinit var requestContext: MobileEngageRequestContext

@Before
fun setUp() {

mockContactFieldValueStorage = mock<Storage<String?>>()
requestContext = MobileEngageRequestContext(
"appCode",
1,
null,
null,
mock(),
mock(),
mock(),
mock(),
mock(),
mock(),
mock(),
mockContactFieldValueStorage,
mock()
)
}
Expand Down Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class DefaultMobileEngageInternal(
Logger.error(CrashLog(it))
}
}
} else {
completionListener?.onCompleted(null)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -20,9 +19,19 @@ data class MobileEngageRequestContext(
val contactTokenStorage: Storage<String?>,
val refreshTokenStorage: Storage<String?>,
val pushTokenStorage: Storage<String?>,
val contactFieldValueStorage: Storage<String?>,
val sessionIdHolder: SessionIdHolder
) {

var contactFieldValue: String?
get() {
return contactFieldValueStorage.get()
}
set(value) {
contactFieldValueStorage.set(value)
}


fun hasContactIdentification(): Boolean {
return openIdToken != null || contactFieldValue != null
}
Expand Down

0 comments on commit 689e819

Please sign in to comment.