From b7190c2bfe7a93f40c504317cc6a85e81cc110af Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 11 Oct 2022 14:39:40 +0200 Subject: [PATCH] Fix after rebase --- .../GetMatrixClientInfoUseCaseTest.kt | 78 ------------------- .../im/vector/app/test/fakes/FakeSession.kt | 1 + 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 vector/src/test/java/im/vector/app/features/settings/devices/v2/details/extended/GetMatrixClientInfoUseCaseTest.kt diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/extended/GetMatrixClientInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/extended/GetMatrixClientInfoUseCaseTest.kt deleted file mode 100644 index 4a90f90c13..0000000000 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/extended/GetMatrixClientInfoUseCaseTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package im.vector.app.features.settings.devices.v2.details.extended - -import MATRIX_CLIENT_INFO_KEY_PREFIX -import im.vector.app.test.fakes.FakeActiveSessionHolder -import org.amshove.kluent.shouldBe -import org.amshove.kluent.shouldBeEqualTo -import org.junit.Test - -private const val A_DEVICE_ID = "device-id" -private const val A_CLIENT_NAME = "client-name" -private const val A_CLIENT_VERSION = "client-version" -private const val A_CLIENT_URL = "client-url" - -class GetMatrixClientInfoUseCaseTest { - - private val fakeActiveSessionHolder = FakeActiveSessionHolder() - - private val getMatrixClientInfoUseCase = GetMatrixClientInfoUseCase( - activeSessionHolder = fakeActiveSessionHolder.instance - ) - - @Test - fun `given a device id and existing content when getting the info then result should contain that info`() { - // Given - givenClientInfoContent(A_DEVICE_ID) - val expectedClientInfo = MatrixClientInfoContent( - name = A_CLIENT_NAME, - version = A_CLIENT_VERSION, - url = A_CLIENT_URL, - ) - - // When - val result = getMatrixClientInfoUseCase.execute(A_DEVICE_ID) - - // Then - result shouldBeEqualTo expectedClientInfo - } - - @Test - fun `given no active session when getting the info then result should be null`() { - // Given - fakeActiveSessionHolder.givenGetSafeActiveSessionReturns(null) - - // When - val result = getMatrixClientInfoUseCase.execute(A_DEVICE_ID) - - // Then - result shouldBe null - } - - private fun givenClientInfoContent(deviceId: String) { - val type = MATRIX_CLIENT_INFO_KEY_PREFIX + deviceId - val content = mapOf( - Pair("name", A_CLIENT_NAME), - Pair("version", A_CLIENT_VERSION), - Pair("url", A_CLIENT_URL), - ) - fakeActiveSessionHolder.fakeSession - .fakeSessionAccountDataService - .givenGetUserAccountDataEventReturns(type, content) - } -} diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakeSession.kt b/vector/src/test/java/im/vector/app/test/fakes/FakeSession.kt index 4dfd44025a..c40e4a8fc4 100644 --- a/vector/src/test/java/im/vector/app/test/fakes/FakeSession.kt +++ b/vector/src/test/java/im/vector/app/test/fakes/FakeSession.kt @@ -61,6 +61,7 @@ class FakeSession( override fun sharedSecretStorageService() = fakeSharedSecretStorageService override fun roomService() = fakeRoomService override fun eventService() = fakeEventService + override fun pushersService() = fakePushersService override fun accountDataService() = fakeSessionAccountDataService override fun filterService() = fakeFilterService