fix uncheck cast warning

This commit is contained in:
valere 2022-12-06 08:17:31 +01:00
parent 2ed212aa11
commit 139eb1708c
1 changed files with 10 additions and 11 deletions

View File

@ -41,16 +41,15 @@ import org.matrix.android.sdk.internal.crypto.model.rest.UpdateDeviceInfoBody
import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody import org.matrix.android.sdk.internal.crypto.model.rest.UploadSigningKeysBody
import org.matrix.android.sdk.internal.crypto.tasks.DefaultSendToDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.DefaultSendToDeviceTask
import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask import org.matrix.android.sdk.internal.crypto.tasks.SendToDeviceTask
import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
class DefaultSendToDeviceTaskTest { class DefaultSendToDeviceTaskTest {
val users = listOf( private val users = listOf(
"@alice:example.com" to listOf("D0", "D1"), "@alice:example.com" to listOf("D0", "D1"),
"bob@example.com" to listOf("D2", "D3") "bob@example.com" to listOf("D2", "D3")
) )
val fakeEncryptedContent = mapOf( private val fakeEncryptedContent = mapOf(
"algorithm" to "m.olm.v1.curve25519-aes-sha2", "algorithm" to "m.olm.v1.curve25519-aes-sha2",
"sender_key" to "gMObR+/4dqL5T4DisRRRYBJpn+OjzFnkyCFOktP6Eyw", "sender_key" to "gMObR+/4dqL5T4DisRRRYBJpn+OjzFnkyCFOktP6Eyw",
"ciphertext" to mapOf( "ciphertext" to mapOf(
@ -67,14 +66,14 @@ class DefaultSendToDeviceTaskTest {
val sendToDeviceTask = DefaultSendToDeviceTask( val sendToDeviceTask = DefaultSendToDeviceTask(
cryptoApi = fakeCryptoAPi, cryptoApi = fakeCryptoAPi,
globalErrorReceiver = mockk<GlobalErrorReceiver>(relaxed = true) globalErrorReceiver = mockk(relaxed = true)
) )
val contentMap = MXUsersDevicesMap<Any>() val contentMap = MXUsersDevicesMap<Any>()
users.forEach { users.forEach { pairOfUserDevices ->
val userId = it.first val userId = pairOfUserDevices.first
it.second.forEach { pairOfUserDevices.second.forEach {
contentMap.setObject(userId, it, fakeEncryptedContent) contentMap.setObject(userId, it, fakeEncryptedContent)
} }
} }
@ -89,10 +88,10 @@ class DefaultSendToDeviceTaskTest {
} }
val generatedIds = mutableListOf<String>() val generatedIds = mutableListOf<String>()
users.forEach { users.forEach { pairOfUserDevices ->
val userId = it.first val userId = pairOfUserDevices.first
it.second.forEach { pairOfUserDevices.second.forEach {
val modifiedContent = fakeCryptoAPi.body!!.messages!![userId]!![it] as Map<String, *> val modifiedContent = fakeCryptoAPi.body!!.messages!![userId]!![it] as Map<*, *>
Assert.assertNotNull("Tracing id should have been added", modifiedContent["org.matrix.msgid"]) Assert.assertNotNull("Tracing id should have been added", modifiedContent["org.matrix.msgid"])
generatedIds.add(modifiedContent["org.matrix.msgid"] as String) generatedIds.add(modifiedContent["org.matrix.msgid"] as String)