From 8bf46b136a5a2fe119d95f94153c14d01bc7117a Mon Sep 17 00:00:00 2001
From: Florian Renaud <florianr@element.io>
Date: Fri, 17 Feb 2023 12:12:55 +0100
Subject: [PATCH] Fix broken test

---
 .../ConfigureAndStartSessionUseCaseTest.kt    | 13 +++++---
 .../fakes/FakeNotificationsSettingUpdater.kt  |  2 +-
 .../app/test/fakes/FakePushRulesUpdater.kt    | 31 +++++++++++++++++++
 3 files changed, 41 insertions(+), 5 deletions(-)
 create mode 100644 vector/src/test/java/im/vector/app/test/fakes/FakePushRulesUpdater.kt

diff --git a/vector/src/test/java/im/vector/app/core/session/ConfigureAndStartSessionUseCaseTest.kt b/vector/src/test/java/im/vector/app/core/session/ConfigureAndStartSessionUseCaseTest.kt
index 786b200ef5..54e249f6b0 100644
--- a/vector/src/test/java/im/vector/app/core/session/ConfigureAndStartSessionUseCaseTest.kt
+++ b/vector/src/test/java/im/vector/app/core/session/ConfigureAndStartSessionUseCaseTest.kt
@@ -22,6 +22,7 @@ import im.vector.app.features.session.coroutineScope
 import im.vector.app.features.settings.devices.v2.notification.UpdateNotificationSettingsAccountDataUseCase
 import im.vector.app.test.fakes.FakeContext
 import im.vector.app.test.fakes.FakeNotificationsSettingUpdater
+import im.vector.app.test.fakes.FakePushRulesUpdater
 import im.vector.app.test.fakes.FakeSession
 import im.vector.app.test.fakes.FakeVectorPreferences
 import im.vector.app.test.fakes.FakeWebRtcCallManager
@@ -47,6 +48,7 @@ class ConfigureAndStartSessionUseCaseTest {
     private val fakeUpdateMatrixClientInfoUseCase = mockk<UpdateMatrixClientInfoUseCase>()
     private val fakeVectorPreferences = FakeVectorPreferences()
     private val fakeNotificationsSettingUpdater = FakeNotificationsSettingUpdater()
+    private val fakePushRulesUpdater = FakePushRulesUpdater()
     private val fakeUpdateNotificationSettingsAccountDataUseCase = mockk<UpdateNotificationSettingsAccountDataUseCase>()
 
     private val configureAndStartSessionUseCase = ConfigureAndStartSessionUseCase(
@@ -56,7 +58,7 @@ class ConfigureAndStartSessionUseCaseTest {
             vectorPreferences = fakeVectorPreferences.instance,
             notificationsSettingUpdater = fakeNotificationsSettingUpdater.instance,
             updateNotificationSettingsAccountDataUseCase = fakeUpdateNotificationSettingsAccountDataUseCase,
-            pushRulesUpdater = mockk(),
+            pushRulesUpdater = fakePushRulesUpdater.instance,
     )
 
     @Before
@@ -79,7 +81,8 @@ class ConfigureAndStartSessionUseCaseTest {
         coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
         coJustRun { fakeUpdateNotificationSettingsAccountDataUseCase.execute(any()) }
         fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = true)
-        fakeNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
+        fakeNotificationsSettingUpdater.givenOnSessionStarted(aSession)
+        fakePushRulesUpdater.givenOnSessionStarted(aSession)
 
         // When
         configureAndStartSessionUseCase.execute(aSession, startSyncing = true)
@@ -103,7 +106,8 @@ class ConfigureAndStartSessionUseCaseTest {
         fakeWebRtcCallManager.givenCheckForProtocolsSupportIfNeededSucceeds()
         coJustRun { fakeUpdateNotificationSettingsAccountDataUseCase.execute(any()) }
         fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = false)
-        fakeNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
+        fakeNotificationsSettingUpdater.givenOnSessionStarted(aSession)
+        fakePushRulesUpdater.givenOnSessionStarted(aSession)
 
         // When
         configureAndStartSessionUseCase.execute(aSession, startSyncing = true)
@@ -130,7 +134,8 @@ class ConfigureAndStartSessionUseCaseTest {
         coJustRun { fakeUpdateMatrixClientInfoUseCase.execute(any()) }
         coJustRun { fakeUpdateNotificationSettingsAccountDataUseCase.execute(any()) }
         fakeVectorPreferences.givenIsClientInfoRecordingEnabled(isEnabled = true)
-        fakeNotificationsSettingUpdater.givenOnSessionsStarted(aSession)
+        fakeNotificationsSettingUpdater.givenOnSessionStarted(aSession)
+        fakePushRulesUpdater.givenOnSessionStarted(aSession)
 
         // When
         configureAndStartSessionUseCase.execute(aSession, startSyncing = false)
diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakeNotificationsSettingUpdater.kt b/vector/src/test/java/im/vector/app/test/fakes/FakeNotificationsSettingUpdater.kt
index 2e397763f8..1fbd59afc9 100644
--- a/vector/src/test/java/im/vector/app/test/fakes/FakeNotificationsSettingUpdater.kt
+++ b/vector/src/test/java/im/vector/app/test/fakes/FakeNotificationsSettingUpdater.kt
@@ -25,7 +25,7 @@ class FakeNotificationsSettingUpdater {
 
     val instance = mockk<NotificationsSettingUpdater>()
 
-    fun givenOnSessionsStarted(session: Session) {
+    fun givenOnSessionStarted(session: Session) {
         justRun { instance.onSessionStarted(session) }
     }
 }
diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakePushRulesUpdater.kt b/vector/src/test/java/im/vector/app/test/fakes/FakePushRulesUpdater.kt
new file mode 100644
index 0000000000..b6e5b8f2ae
--- /dev/null
+++ b/vector/src/test/java/im/vector/app/test/fakes/FakePushRulesUpdater.kt
@@ -0,0 +1,31 @@
+/*
+ * 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.test.fakes
+
+import im.vector.app.core.notification.PushRulesUpdater
+import io.mockk.justRun
+import io.mockk.mockk
+import org.matrix.android.sdk.api.session.Session
+
+class FakePushRulesUpdater {
+
+    val instance = mockk<PushRulesUpdater>()
+
+    fun givenOnSessionStarted(session: Session) {
+        justRun { instance.onSessionStarted(session) }
+    }
+}