diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManagerTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManagerTest.kt index bbe5e273b2..7d1e806911 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManagerTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/DefaultNotificationDrawerManagerTest.kt @@ -72,7 +72,7 @@ class DefaultNotificationDrawerManagerTest { // For now just call all the API. Later, add more valuable tests. val matrixUser = aMatrixUser(id = A_SESSION_ID.value, displayName = "alice", avatarUrl = "mxc://data") val mockRoomGroupMessageCreator = FakeRoomGroupMessageCreator( - createRoomMessageResult = lambdaRecorder { user, _, roomId, _, existingNotification, -> + createRoomMessageResult = lambdaRecorder { user, _, roomId, _, existingNotification -> assertThat(user).isEqualTo(matrixUser) assertThat(roomId).isEqualTo(A_ROOM_ID) assertThat(existingNotification).isNull() @@ -167,11 +167,12 @@ class DefaultNotificationDrawerManagerTest { } val summaryId = NotificationIdProvider.getSummaryNotificationId(A_SESSION_ID) val activeNotificationsProvider = FakeActiveNotificationsProvider( - mutableListOf( + getSummaryNotificationResult = { mockk { every { id } returns summaryId } - ) + }, + countResult = { 1 }, ) val defaultNotificationDrawerManager = createDefaultNotificationDrawerManager( notificationManager = notificationManager, diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeActiveNotificationsProvider.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeActiveNotificationsProvider.kt index a5d306842f..d99a4264c0 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeActiveNotificationsProvider.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeActiveNotificationsProvider.kt @@ -22,29 +22,34 @@ import io.element.android.libraries.matrix.api.core.SessionId import io.element.android.libraries.push.impl.notifications.ActiveNotificationsProvider class FakeActiveNotificationsProvider( - var activeNotifications: MutableList = mutableListOf(), + private val getMessageNotificationsForRoomResult: (SessionId, RoomId) -> List = { _, _ -> emptyList() }, + private val getNotificationsForSessionResult: (SessionId) -> List = { emptyList() }, + private val getMembershipNotificationForSessionResult: (SessionId) -> List = { emptyList() }, + private val getMembershipNotificationForRoomResult: (SessionId, RoomId) -> List = { _, _ -> emptyList() }, + private val getSummaryNotificationResult: (SessionId) -> StatusBarNotification? = { null }, + private val countResult: (SessionId) -> Int = { 0 }, ) : ActiveNotificationsProvider { override fun getMessageNotificationsForRoom(sessionId: SessionId, roomId: RoomId): List { - return activeNotifications + return getMessageNotificationsForRoomResult(sessionId, roomId) } override fun getNotificationsForSession(sessionId: SessionId): List { - return activeNotifications + return getNotificationsForSessionResult(sessionId) } override fun getMembershipNotificationForSession(sessionId: SessionId): List { - return activeNotifications + return getMembershipNotificationForSessionResult(sessionId) } override fun getMembershipNotificationForRoom(sessionId: SessionId, roomId: RoomId): List { - return activeNotifications + return getMembershipNotificationForRoomResult(sessionId, roomId) } override fun getSummaryNotification(sessionId: SessionId): StatusBarNotification? { - return activeNotifications.firstOrNull() + return getSummaryNotificationResult(sessionId) } override fun count(sessionId: SessionId): Int { - return activeNotifications.size + return countResult(sessionId) } }