Coverage Summary for Class: InAppSerializationManagerImpl (cloud.mindbox.mobile_sdk.inapp.data.managers)
| Class |
Method, %
|
Branch, %
|
Line, %
|
Instruction, %
|
| InAppSerializationManagerImpl |
100%
(7/7)
|
|
100%
(7/7)
|
100%
(66/66)
|
| InAppSerializationManagerImpl$deserializeToShownInApps$1 |
100%
(1/1)
|
100%
(2/2)
|
100%
(4/4)
|
100%
(15/15)
|
| InAppSerializationManagerImpl$deserializeToShownInApps$1$1 |
100%
(1/1)
|
|
100%
(1/1)
|
100%
(2/2)
|
| InAppSerializationManagerImpl$deserializeToShownInAppsMap$1 |
100%
(1/1)
|
50%
(1/2)
|
100%
(1/1)
|
70.6%
(12/17)
|
| InAppSerializationManagerImpl$deserializeToShownInAppsMap$1$invoke$$inlined$fromJsonTyped$1 |
0%
(0/1)
|
|
| InAppSerializationManagerImpl$serializeToInAppActionString$1 |
100%
(1/1)
|
|
100%
(1/1)
|
100%
(12/12)
|
| InAppSerializationManagerImpl$serializeToInAppActionString$1$invoke$$inlined$toJsonTyped$1 |
0%
(0/1)
|
|
| InAppSerializationManagerImpl$serializeToInAppShowFailuresString$1 |
100%
(1/1)
|
|
100%
(1/1)
|
100%
(12/12)
|
| InAppSerializationManagerImpl$serializeToInAppShowFailuresString$1$invoke$$inlined$toJsonTyped$1 |
0%
(0/1)
|
|
| InAppSerializationManagerImpl$serializeToInAppShownActionString$1 |
100%
(1/1)
|
|
100%
(5/5)
|
100%
(17/17)
|
| InAppSerializationManagerImpl$serializeToInAppShownActionString$1$invoke$$inlined$toJsonTyped$1 |
0%
(0/1)
|
|
| InAppSerializationManagerImpl$serializeToShownInAppsString$1 |
100%
(1/1)
|
|
100%
(1/1)
|
100%
(9/9)
|
| InAppSerializationManagerImpl$serializeToShownInAppsString$1$invoke$$inlined$toJsonTyped$1 |
0%
(0/1)
|
|
| Total |
73.7%
(14/19)
|
75%
(3/4)
|
100%
(21/21)
|
96.7%
(145/150)
|
package cloud.mindbox.mobile_sdk.inapp.data.managers
import cloud.mindbox.mobile_sdk.fromJsonTyped
import cloud.mindbox.mobile_sdk.inapp.domain.interfaces.managers.InAppSerializationManager
import cloud.mindbox.mobile_sdk.inapp.domain.models.InAppFailuresWrapper
import cloud.mindbox.mobile_sdk.models.operation.request.InAppHandleRequest
import cloud.mindbox.mobile_sdk.models.operation.request.InAppShowRequest
import cloud.mindbox.mobile_sdk.models.operation.request.InAppShowFailure
import cloud.mindbox.mobile_sdk.toJsonTyped
import cloud.mindbox.mobile_sdk.utils.LoggingExceptionHandler
import cloud.mindbox.mobile_sdk.utils.loggingRunCatching
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
internal class InAppSerializationManagerImpl(private val gson: Gson) : InAppSerializationManager {
override fun serializeToInAppShownActionString(
inAppId: String,
timeToDisplay: String,
tags: Map<String, String>?,
): String {
return loggingRunCatching("") {
gson.toJsonTyped<InAppShowRequest>(
InAppShowRequest(
inAppId = inAppId,
timeToDisplay = timeToDisplay,
tags = tags,
)
)
}
}
override fun serializeToInAppActionString(inAppId: String): String {
return loggingRunCatching("") {
gson.toJsonTyped<InAppHandleRequest>(InAppHandleRequest(inAppId = inAppId))
}
}
override fun serializeToShownInAppsString(shownInApps: Map<String, List<Long>>): String {
return loggingRunCatching("") {
gson.toJsonTyped<Map<String, List<Long>>>(shownInApps)
}
}
override fun serializeToInAppShowFailuresString(
inAppShowFailures: List<InAppShowFailure>
): String {
return loggingRunCatching("") {
gson.toJsonTyped<InAppFailuresWrapper>(InAppFailuresWrapper(inAppShowFailures))
}
}
override fun deserializeToShownInAppsMap(shownInApps: String): Map<String, List<Long>> {
return loggingRunCatching(hashMapOf()) {
gson.fromJsonTyped<Map<String, List<Long>>>(shownInApps) ?: hashMapOf()
}
}
override fun deserializeToShownInApps(shownInApps: String): Set<String> {
return LoggingExceptionHandler.runCatching(HashSet()) {
gson.fromJson(
shownInApps,
object : TypeToken<HashSet<String>>() {}.type
) ?: emptySet()
}
}
}