diff --git a/config/detekt/baseline.xml b/config/detekt/baseline.xml
index 4c50fef9..dc412a27 100644
--- a/config/detekt/baseline.xml
+++ b/config/detekt/baseline.xml
@@ -153,20 +153,20 @@
MaximumLineLength:com.qonversion.android.sdk.dto.products.QProduct.kt:120
MaximumLineLength:com.qonversion.android.sdk.dto.products.QProduct.kt:139
MaximumLineLength:com.qonversion.android.sdk.dto.products.QProductStoreDetails.kt:130
- MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:213
- MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:370
- MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:429
+ MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:214
+ MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:371
+ MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:430
MaximumLineLength:com.qonversion.android.sdk.internal.OutagerIntegrationTest.kt:90
MaximumLineLength:com.qonversion.android.sdk.internal.QProductCenterManager.kt:332
MaximumLineLength:com.qonversion.android.sdk.internal.QProductCenterManagerTest.kt:152
MaximumLineLength:com.qonversion.android.sdk.internal.QProductCenterManagerTest.kt:153
MaximumLineLength:com.qonversion.android.sdk.internal.QRemoteConfigManager.kt:225
MaximumLineLength:com.qonversion.android.sdk.internal.QUserPropertiesManagerTest.kt:175
- MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:286
- MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:355
- MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:684
+ MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:287
+ MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:356
+ MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:685
MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:89
- MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:905
+ MaximumLineLength:com.qonversion.android.sdk.internal.QonversionRepositoryIntegrationTest.kt:906
MaximumLineLength:com.qonversion.android.sdk.internal.api.ApiErrorMapper.kt:118
MaximumLineLength:com.qonversion.android.sdk.internal.api.ApiErrorMapper.kt:119
MaximumLineLength:com.qonversion.android.sdk.internal.billing.QonversionBillingService.kt:253
diff --git a/sdk/build.gradle b/sdk/build.gradle
index 4dfeb02b..542892d8 100644
--- a/sdk/build.gradle
+++ b/sdk/build.gradle
@@ -161,8 +161,8 @@ dependencies {
androidTestImplementation "org.robolectric:robolectric:4.10.3"
// MockK
- testImplementation 'io.mockk:mockk:1.10.0'
- androidTestImplementation 'io.mockk:mockk-android:1.10.0'
+ testImplementation 'io.mockk:mockk:1.11.0'
+ androidTestImplementation 'io.mockk:mockk-android:1.11.0'
// Mockito
testImplementation 'org.mockito:mockito-core:4.3.1'
diff --git a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt
index b1e15204..6040f904 100644
--- a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt
+++ b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/OutagerIntegrationTest.kt
@@ -88,6 +88,7 @@ internal class OutagerIntegrationTest {
originalOrderId = "GPA.3307-0767-0668-99058",
purchaseTime = 1679933171,
purchaseToken = "lgeigljfpmeoddkcebkcepjc.AO-J1Oy305qZj99jXTPEVBN8UZGoYAtjDLj4uTjRQvUFaG0vie-nr6VBlN0qnNDMU8eJR-sI7o3CwQyMOEHKl8eJsoQ86KSFzxKBR07PSpHLI_o7agXhNKY",
+ contextKeys = null
)
@Test
diff --git a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt
index cae0e34e..3fd282b7 100644
--- a/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt
+++ b/sdk/src/androidTest/java/com/qonversion/android/sdk/internal/QonversionRepositoryIntegrationTest.kt
@@ -87,6 +87,7 @@ internal class QonversionRepositoryIntegrationTest {
originalOrderId = "GPA.3307-0767-0668-99058",
purchaseTime = 1679933171,
purchaseToken = "lgeigljfpmeoddkcebkcepjc.AO-J1Oy305qZj99jXTPEVBN8UZGoYAtjDLj4uTjRQvUFaG0vie-nr6VBlN0qnNDMU8eJR-sI7o3CwQyMOEHKl8eJsoQ86KSFzxKBR07PSpHLI_o7agXhNKY",
+ contextKeys = null
)
@Test
diff --git a/sdk/src/test/java/com/qonversion/android/sdk/internal/QProductCenterManagerTest.kt b/sdk/src/test/java/com/qonversion/android/sdk/internal/QProductCenterManagerTest.kt
index 619ba9fc..72ee3311 100644
--- a/sdk/src/test/java/com/qonversion/android/sdk/internal/QProductCenterManagerTest.kt
+++ b/sdk/src/test/java/com/qonversion/android/sdk/internal/QProductCenterManagerTest.kt
@@ -161,7 +161,7 @@ internal class QProductCenterManagerTest {
val purchase = mockk(relaxed = true)
- every { purchase.productId } returns productId
+ every { purchase.products } returns listOf(productId)
every { purchase.purchaseToken } returns purchaseToken
every { purchase.purchaseState } returns purchaseState
every { purchase.isAcknowledged } returns isAcknowledged
diff --git a/sdk/src/test/java/com/qonversion/android/sdk/internal/QUserPropertiesManagerTest.kt b/sdk/src/test/java/com/qonversion/android/sdk/internal/QUserPropertiesManagerTest.kt
index 80d16b6a..33a96283 100644
--- a/sdk/src/test/java/com/qonversion/android/sdk/internal/QUserPropertiesManagerTest.kt
+++ b/sdk/src/test/java/com/qonversion/android/sdk/internal/QUserPropertiesManagerTest.kt
@@ -36,6 +36,7 @@ internal class QUserPropertiesManagerTest {
private val fieldRetryDelay = "retryDelay"
private val fieldRetriesCounter = "retriesCounter"
private val fieldIsSendingScheduled = "isSendingScheduled"
+ private val fieldHandler = "handler"
private val minDelay = 5
private val calculatedDelay = 1
private val properties = mapOf("someKey" to "someValue")
@@ -54,7 +55,7 @@ internal class QUserPropertiesManagerTest {
mockkConstructor(Handler::class)
mockHandler = Handler(mockLooper)
- propertiesManager =
+ propertiesManager = spyk(
QUserPropertiesManager(
mockContext,
mockRepository,
@@ -63,6 +64,8 @@ internal class QUserPropertiesManagerTest {
mockAppStateProvider,
mockLogger
)
+ )
+ propertiesManager.mockPrivateField(fieldHandler, mockHandler)
}
@Test
@@ -340,35 +343,31 @@ internal class QUserPropertiesManagerTest {
@Test
fun `should set and not send user property when sending properties is scheduled`() {
// given
- val handlerDelay = (minDelay * 1000).toLong()
val key = "email"
val value = "some value"
- val spykPropertiesManager = spyk(propertiesManager, recordPrivateCalls = true)
- spykPropertiesManager.mockPrivateField(fieldIsSendingScheduled, true)
- mockPostDelayed(handlerDelay)
+ propertiesManager.mockPrivateField(fieldIsSendingScheduled, true)
+ every { propertiesManager.sendPropertiesWithDelay(any()) } just runs
// when
- spykPropertiesManager.setCustomUserProperty(key, value)
+ propertiesManager.setCustomUserProperty(key, value)
// then
+ verify {
+ mockPropertiesStorage.save(key, value)
+ }
verify(exactly = 0) {
- spykPropertiesManager.forceSendProperties()
+ propertiesManager.sendPropertiesWithDelay(any())
}
}
@Test
- fun `should set and send user property when it is not empty and sending is not scheduled on foreground`() {
+ fun `should set and send user property when it is not empty and sending is not scheduled`() {
// given
val key = "_q_email"
val value = "some value"
- val handlerDelay = (minDelay * 1000).toLong()
- mockPostDelayed(handlerDelay)
every { mockAppStateProvider.appState } returns AppState.Foreground
-
- every {
- propertiesManager.forceSendProperties()
- } just Runs
+ every { propertiesManager.sendPropertiesWithDelay(any()) } just runs
// when
propertiesManager.setCustomUserProperty(key, value)
@@ -376,33 +375,7 @@ internal class QUserPropertiesManagerTest {
// then
verifyOrder {
mockPropertiesStorage.save(key, value)
- mockHandler.postDelayed(any(), handlerDelay)
- propertiesManager.forceSendProperties()
- }
-
- val isSendingScheduled = propertiesManager.getPrivateField(fieldIsSendingScheduled)
- assertEquals("The field isSendingScheduled is not equal true", true, isSendingScheduled)
- }
-
- @Test
- fun `should set and not send user property when it is not empty and sending is not scheduled on background`() {
- // given
- val key = "_q_email"
- val value = "some value"
- every { mockAppStateProvider.appState } returns AppState.Background
-
- // when
- propertiesManager.setCustomUserProperty(key, value)
-
- // then
- val isSendingScheduled = propertiesManager.getPrivateField(fieldIsSendingScheduled)
- assertEquals("The field isSendingScheduled is not equal false", false, isSendingScheduled)
- verify(exactly = 1) {
- mockPropertiesStorage.save(key, value)
- }
- verify(exactly = 0) {
- mockHandler.postDelayed(any(), any())
- propertiesManager.forceSendProperties()
+ propertiesManager.sendPropertiesWithDelay(minDelay)
}
}
@@ -464,9 +437,7 @@ internal class QUserPropertiesManagerTest {
val handlerDelay = (minDelay * 1000).toLong()
mockPostDelayed(handlerDelay)
- every {
- propertiesManager.forceSendProperties()
- } just Runs
+ every { propertiesManager.forceSendProperties() } just Runs
// when
propertiesManager.sendPropertiesWithDelay(minDelay)