From 39a0b3b1ba273cd9a507e5df922c773afb325c95 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Mon, 5 Sep 2022 16:01:22 +0200 Subject: [PATCH] Moving recently created use cases inside v2 package --- .../app/features/settings/devices/DevicesViewModel.kt | 1 + .../settings/devices/v2/GetDeviceFullInfoListUseCase.kt | 1 - .../GetEncryptionTrustLevelForCurrentDeviceUseCase.kt | 2 +- .../{ => v2}/GetEncryptionTrustLevelForDeviceUseCase.kt | 2 +- .../GetEncryptionTrustLevelForOtherDeviceUseCase.kt | 2 +- .../devices/v2/overview/GetDeviceFullInfoUseCase.kt | 9 +++++---- ...GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt | 2 +- .../GetEncryptionTrustLevelForDeviceUseCaseTest.kt | 5 ++--- .../GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) rename vector/src/main/java/im/vector/app/features/settings/devices/{ => v2}/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt (96%) rename vector/src/main/java/im/vector/app/features/settings/devices/{ => v2}/GetEncryptionTrustLevelForDeviceUseCase.kt (97%) rename vector/src/main/java/im/vector/app/features/settings/devices/{ => v2}/GetEncryptionTrustLevelForOtherDeviceUseCase.kt (97%) rename vector/src/test/java/im/vector/app/features/settings/devices/{ => v2}/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt (97%) rename vector/src/test/java/im/vector/app/features/settings/devices/{ => v2}/GetEncryptionTrustLevelForDeviceUseCaseTest.kt (96%) rename vector/src/test/java/im/vector/app/features/settings/devices/{ => v2}/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt (98%) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/DevicesViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/DevicesViewModel.kt index 82c346b09c..30e7727860 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/DevicesViewModel.kt @@ -34,6 +34,7 @@ import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.PublishDataSource import im.vector.app.features.auth.ReAuthActivity import im.vector.app.features.login.ReAuthHelper +import im.vector.app.features.settings.devices.v2.GetEncryptionTrustLevelForDeviceUseCase import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase import im.vector.lib.core.utils.flow.throttleFirst import kotlinx.coroutines.Dispatchers diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt index fbe6609ef4..948d23de39 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetDeviceFullInfoListUseCase.kt @@ -17,7 +17,6 @@ package im.vector.app.features.settings.devices.v2 import im.vector.app.core.di.ActiveSessionHolder -import im.vector.app.features.settings.devices.GetEncryptionTrustLevelForDeviceUseCase import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt similarity index 96% rename from vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt rename to vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt index 0d30aba318..7e56d35570 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForCurrentDeviceUseCase.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel import javax.inject.Inject diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForDeviceUseCase.kt similarity index 97% rename from vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt rename to vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForDeviceUseCase.kt index 433c4da233..7f330b71d5 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForDeviceUseCase.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForOtherDeviceUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForOtherDeviceUseCase.kt similarity index 97% rename from vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForOtherDeviceUseCase.kt rename to vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForOtherDeviceUseCase.kt index 11bc3a8ede..7541b9b1d5 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForOtherDeviceUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForOtherDeviceUseCase.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt index a8a97ab326..60c6266901 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt @@ -19,8 +19,8 @@ package im.vector.app.features.settings.devices.v2.overview import androidx.lifecycle.asFlow import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.features.settings.devices.v2.DeviceFullInfo -import im.vector.app.features.settings.devices.GetCurrentSessionCrossSigningInfoUseCase -import im.vector.app.features.settings.devices.GetEncryptionTrustLevelForDeviceUseCase +import im.vector.app.features.settings.devices.v2.GetCurrentSessionCrossSigningInfoUseCase +import im.vector.app.features.settings.devices.v2.GetEncryptionTrustLevelForDeviceUseCase import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveUseCase import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine @@ -29,6 +29,7 @@ import org.matrix.android.sdk.api.util.Optional import org.matrix.android.sdk.api.util.toOptional import javax.inject.Inject +// TODO update unit tests class GetDeviceFullInfoUseCase @Inject constructor( private val activeSessionHolder: ActiveSessionHolder, private val getCurrentSessionCrossSigningInfoUseCase: GetCurrentSessionCrossSigningInfoUseCase, @@ -38,11 +39,11 @@ class GetDeviceFullInfoUseCase @Inject constructor( fun execute(deviceId: String): Flow> { return activeSessionHolder.getSafeActiveSession()?.let { session -> - val currentSessionCrossSigningInfo = getCurrentSessionCrossSigningInfoUseCase.execute() combine( + getCurrentSessionCrossSigningInfoUseCase.execute(), session.cryptoService().getMyDevicesInfoLive(deviceId).asFlow(), session.cryptoService().getLiveCryptoDeviceInfoWithId(deviceId).asFlow() - ) { deviceInfo, cryptoDeviceInfo -> + ) { currentSessionCrossSigningInfo, deviceInfo, cryptoDeviceInfo -> val info = deviceInfo.getOrNull() val cryptoInfo = cryptoDeviceInfo.getOrNull() val fullInfo = if (info != null && cryptoInfo != null) { diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt similarity index 97% rename from vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt rename to vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt index 830eab5dcb..b2ce89df33 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForCurrentDeviceUseCaseTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 import org.amshove.kluent.shouldBeEqualTo import org.junit.Test diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForDeviceUseCaseTest.kt similarity index 96% rename from vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt rename to vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForDeviceUseCaseTest.kt index e55f0969f7..e43fd49ffc 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForDeviceUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForDeviceUseCaseTest.kt @@ -14,9 +14,8 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 -import im.vector.app.features.settings.devices.v2.CurrentSessionCrossSigningInfo import io.mockk.every import io.mockk.mockk import io.mockk.verify @@ -91,7 +90,7 @@ class GetEncryptionTrustLevelForDeviceUseCaseTest { } private fun givenCurrentSessionCrossSigningInfo( - deviceId: String?, + deviceId: String, isCrossSigningInitialized: Boolean, isCrossSigningVerified: Boolean ): CurrentSessionCrossSigningInfo { diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt similarity index 98% rename from vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt rename to vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt index 9dc87c2a16..2aeffbbb0d 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/GetEncryptionTrustLevelForOtherDeviceUseCaseTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package im.vector.app.features.settings.devices +package im.vector.app.features.settings.devices.v2 import org.amshove.kluent.shouldBeEqualTo import org.junit.Test