Rename Fake class with Mockk prefix for clarity

This commit is contained in:
Benoit Marty 2024-03-26 11:49:57 +01:00 committed by Benoit Marty
parent 8588ce7a72
commit e9308400bd
11 changed files with 63 additions and 63 deletions

View file

@ -23,10 +23,10 @@ import io.element.android.libraries.matrix.test.A_SPACE_ID
import io.element.android.libraries.matrix.test.A_THREAD_ID import io.element.android.libraries.matrix.test.A_THREAD_ID
import io.element.android.libraries.matrix.test.FakeMatrixClientProvider import io.element.android.libraries.matrix.test.FakeMatrixClientProvider
import io.element.android.libraries.matrix.test.core.aBuildMeta import io.element.android.libraries.matrix.test.core.aBuildMeta
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationCreator
import io.element.android.libraries.push.impl.notifications.fake.FakeImageLoaderHolder import io.element.android.libraries.push.impl.notifications.fake.FakeImageLoaderHolder
import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationCreator
import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator import io.element.android.libraries.push.impl.notifications.fake.MockkRoomGroupMessageCreator
import io.element.android.libraries.push.impl.notifications.fake.MockkSummaryGroupMessageCreator
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
import io.element.android.services.appnavstate.api.AppNavigationState import io.element.android.services.appnavstate.api.AppNavigationState
@ -115,12 +115,12 @@ class DefaultNotificationDrawerManagerTest {
appNavigationStateService = appNavigationStateService appNavigationStateService = appNavigationStateService
), ),
notificationRenderer = NotificationRenderer( notificationRenderer = NotificationRenderer(
NotificationIdProvider(), notificationIdProvider = NotificationIdProvider(),
NotificationDisplayer(context), notificationDisplayer = NotificationDisplayer(context),
NotificationFactory( notificationFactory = NotificationFactory(
FakeNotificationCreator().instance, notificationCreator = MockkNotificationCreator().instance,
FakeRoomGroupMessageCreator().instance, roomGroupMessageCreator = MockkRoomGroupMessageCreator().instance,
FakeSummaryGroupMessageCreator().instance, summaryGroupMessageCreator = MockkSummaryGroupMessageCreator().instance,
) )
), ),
notificationEventPersistence = InMemoryNotificationEventPersistence(initialData = initialData), notificationEventPersistence = InMemoryNotificationEventPersistence(initialData = initialData),

View file

@ -25,7 +25,7 @@ import io.element.android.libraries.matrix.test.A_ROOM_ID_2
import io.element.android.libraries.matrix.test.A_SESSION_ID import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.matrix.test.A_SPACE_ID import io.element.android.libraries.matrix.test.A_SPACE_ID
import io.element.android.libraries.matrix.test.A_THREAD_ID import io.element.android.libraries.matrix.test.A_THREAD_ID
import io.element.android.libraries.push.impl.notifications.fake.FakeOutdatedEventDetector import io.element.android.libraries.push.impl.notifications.fake.MockkOutdatedEventDetector
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
import io.element.android.libraries.push.impl.notifications.fixtures.aSimpleNotifiableEvent import io.element.android.libraries.push.impl.notifications.fixtures.aSimpleNotifiableEvent
import io.element.android.libraries.push.impl.notifications.fixtures.anInviteNotifiableEvent import io.element.android.libraries.push.impl.notifications.fixtures.anInviteNotifiableEvent
@ -42,7 +42,7 @@ private val VIEWING_A_ROOM = aNavigationState(A_SESSION_ID, A_SPACE_ID, A_ROOM_I
private val VIEWING_A_THREAD = aNavigationState(A_SESSION_ID, A_SPACE_ID, A_ROOM_ID, A_THREAD_ID) private val VIEWING_A_THREAD = aNavigationState(A_SESSION_ID, A_SPACE_ID, A_ROOM_ID, A_THREAD_ID)
class NotifiableEventProcessorTest { class NotifiableEventProcessorTest {
private val outdatedDetector = FakeOutdatedEventDetector() private val mockkOutdatedDetector = MockkOutdatedEventDetector()
@Test @Test
fun `given simple events when processing then keep simple events`() { fun `given simple events when processing then keep simple events`() {
@ -97,7 +97,7 @@ class NotifiableEventProcessorTest {
@Test @Test
fun `given out of date message event when processing then removes message event`() { fun `given out of date message event when processing then removes message event`() {
val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)) val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID))
outdatedDetector.givenEventIsOutOfDate(events[0]) mockkOutdatedDetector.givenEventIsOutOfDate(events[0])
val eventProcessor = createProcessor(navigationState = NOT_VIEWING_A_ROOM) val eventProcessor = createProcessor(navigationState = NOT_VIEWING_A_ROOM)
@ -113,7 +113,7 @@ class NotifiableEventProcessorTest {
@Test @Test
fun `given in date message event when processing then keep message event`() { fun `given in date message event when processing then keep message event`() {
val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)) val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID))
outdatedDetector.givenEventIsInDate(events[0]) mockkOutdatedDetector.givenEventIsInDate(events[0])
val eventProcessor = createProcessor(navigationState = NOT_VIEWING_A_ROOM) val eventProcessor = createProcessor(navigationState = NOT_VIEWING_A_ROOM)
val result = eventProcessor.process(events, renderedEvents = emptyList()) val result = eventProcessor.process(events, renderedEvents = emptyList())
@ -128,7 +128,7 @@ class NotifiableEventProcessorTest {
@Test @Test
fun `given viewing the same room main timeline when processing main timeline message event then removes message`() { fun `given viewing the same room main timeline when processing main timeline message event then removes message`() {
val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID, threadId = null)) val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID, threadId = null))
events.forEach { outdatedDetector.givenEventIsOutOfDate(it) } events.forEach { mockkOutdatedDetector.givenEventIsOutOfDate(it) }
val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_ROOM) val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_ROOM)
val result = eventProcessor.process(events, renderedEvents = emptyList()) val result = eventProcessor.process(events, renderedEvents = emptyList())
@ -143,7 +143,7 @@ class NotifiableEventProcessorTest {
@Test @Test
fun `given viewing the same thread timeline when processing thread message event then removes message`() { fun `given viewing the same thread timeline when processing thread message event then removes message`() {
val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID, threadId = A_THREAD_ID)) val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID, threadId = A_THREAD_ID))
events.forEach { outdatedDetector.givenEventIsOutOfDate(it) } events.forEach { mockkOutdatedDetector.givenEventIsOutOfDate(it) }
val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_THREAD) val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_THREAD)
val result = eventProcessor.process(events, renderedEvents = emptyList()) val result = eventProcessor.process(events, renderedEvents = emptyList())
@ -158,7 +158,7 @@ class NotifiableEventProcessorTest {
@Test @Test
fun `given viewing main timeline of the same room when processing thread timeline message event then keep message`() { fun `given viewing main timeline of the same room when processing thread timeline message event then keep message`() {
val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID, threadId = A_THREAD_ID)) val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID, threadId = A_THREAD_ID))
outdatedDetector.givenEventIsInDate(events[0]) mockkOutdatedDetector.givenEventIsInDate(events[0])
val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_ROOM) val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_ROOM)
val result = eventProcessor.process(events, renderedEvents = emptyList()) val result = eventProcessor.process(events, renderedEvents = emptyList())
@ -173,7 +173,7 @@ class NotifiableEventProcessorTest {
@Test @Test
fun `given viewing thread timeline of the same room when processing main timeline message event then keep message`() { fun `given viewing thread timeline of the same room when processing main timeline message event then keep message`() {
val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID)) val events = listOf(aNotifiableMessageEvent(eventId = AN_EVENT_ID, roomId = A_ROOM_ID))
outdatedDetector.givenEventIsInDate(events[0]) mockkOutdatedDetector.givenEventIsInDate(events[0])
val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_THREAD) val eventProcessor = createProcessor(isInForeground = true, navigationState = VIEWING_A_THREAD)
val result = eventProcessor.process(events, renderedEvents = emptyList()) val result = eventProcessor.process(events, renderedEvents = emptyList())
@ -213,8 +213,8 @@ class NotifiableEventProcessorTest {
navigationState: NavigationState navigationState: NavigationState
): NotifiableEventProcessor { ): NotifiableEventProcessor {
return NotifiableEventProcessor( return NotifiableEventProcessor(
outdatedDetector.instance, outdatedDetector = mockkOutdatedDetector.instance,
FakeAppNavigationStateService(MutableStateFlow(AppNavigationState(navigationState, isInForeground))), appNavigationStateService = FakeAppNavigationStateService(MutableStateFlow(AppNavigationState(navigationState, isInForeground))),
) )
} }
} }

View file

@ -22,10 +22,10 @@ import io.element.android.libraries.matrix.api.user.MatrixUser
import io.element.android.libraries.matrix.test.AN_EVENT_ID import io.element.android.libraries.matrix.test.AN_EVENT_ID
import io.element.android.libraries.matrix.test.A_ROOM_ID import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.matrix.test.A_SESSION_ID import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationCreator
import io.element.android.libraries.push.impl.notifications.fake.FakeImageLoader import io.element.android.libraries.push.impl.notifications.fake.FakeImageLoader
import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationCreator
import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator import io.element.android.libraries.push.impl.notifications.fake.MockkRoomGroupMessageCreator
import io.element.android.libraries.push.impl.notifications.fake.MockkSummaryGroupMessageCreator
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
import io.element.android.libraries.push.impl.notifications.fixtures.aSimpleNotifiableEvent import io.element.android.libraries.push.impl.notifications.fixtures.aSimpleNotifiableEvent
import io.element.android.libraries.push.impl.notifications.fixtures.anInviteNotifiableEvent import io.element.android.libraries.push.impl.notifications.fixtures.anInviteNotifiableEvent
@ -41,19 +41,19 @@ private val A_MESSAGE_EVENT = aNotifiableMessageEvent(eventId = AN_EVENT_ID, roo
@RunWith(RobolectricTestRunner::class) @RunWith(RobolectricTestRunner::class)
class NotificationFactoryTest { class NotificationFactoryTest {
private val androidNotificationFactory = FakeNotificationCreator() private val mockkNotificationCreator = MockkNotificationCreator()
private val roomGroupMessageCreator = FakeRoomGroupMessageCreator() private val mockkRoomGroupMessageCreator = MockkRoomGroupMessageCreator()
private val summaryGroupMessageCreator = FakeSummaryGroupMessageCreator() private val mockkSummaryGroupMessageCreator = MockkSummaryGroupMessageCreator()
private val notificationFactory = NotificationFactory( private val notificationFactory = NotificationFactory(
androidNotificationFactory.instance, notificationCreator = mockkNotificationCreator.instance,
roomGroupMessageCreator.instance, roomGroupMessageCreator = mockkRoomGroupMessageCreator.instance,
summaryGroupMessageCreator.instance summaryGroupMessageCreator = mockkSummaryGroupMessageCreator.instance
) )
@Test @Test
fun `given a room invitation when mapping to notification then is Append`() = testWith(notificationFactory) { fun `given a room invitation when mapping to notification then is Append`() = testWith(notificationFactory) {
val expectedNotification = androidNotificationFactory.givenCreateRoomInvitationNotificationFor(AN_INVITATION_EVENT) val expectedNotification = mockkNotificationCreator.givenCreateRoomInvitationNotificationFor(AN_INVITATION_EVENT)
val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, AN_INVITATION_EVENT)) val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, AN_INVITATION_EVENT))
val result = roomInvitation.toNotifications() val result = roomInvitation.toNotifications()
@ -90,7 +90,7 @@ class NotificationFactoryTest {
@Test @Test
fun `given a simple event when mapping to notification then is Append`() = testWith(notificationFactory) { fun `given a simple event when mapping to notification then is Append`() = testWith(notificationFactory) {
val expectedNotification = androidNotificationFactory.givenCreateSimpleInvitationNotificationFor(A_SIMPLE_EVENT) val expectedNotification = mockkNotificationCreator.givenCreateSimpleInvitationNotificationFor(A_SIMPLE_EVENT)
val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, A_SIMPLE_EVENT)) val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, A_SIMPLE_EVENT))
val result = roomInvitation.toNotifications() val result = roomInvitation.toNotifications()
@ -128,7 +128,7 @@ class NotificationFactoryTest {
@Test @Test
fun `given room with message when mapping to notification then delegates to room group message creator`() = testWith(notificationFactory) { fun `given room with message when mapping to notification then delegates to room group message creator`() = testWith(notificationFactory) {
val events = listOf(A_MESSAGE_EVENT) val events = listOf(A_MESSAGE_EVENT)
val expectedNotification = roomGroupMessageCreator.givenCreatesRoomMessageFor( val expectedNotification = mockkRoomGroupMessageCreator.givenCreatesRoomMessageFor(
MatrixUser(A_SESSION_ID, A_SESSION_ID.value, MY_AVATAR_URL), MatrixUser(A_SESSION_ID, A_SESSION_ID.value, MY_AVATAR_URL),
events, events,
A_ROOM_ID A_ROOM_ID
@ -197,7 +197,7 @@ class NotificationFactoryTest {
) )
) )
val withRedactedRemoved = listOf(A_MESSAGE_EVENT.copy(eventId = EventId("\$not-redacted"))) val withRedactedRemoved = listOf(A_MESSAGE_EVENT.copy(eventId = EventId("\$not-redacted")))
val expectedNotification = roomGroupMessageCreator.givenCreatesRoomMessageFor( val expectedNotification = mockkRoomGroupMessageCreator.givenCreatesRoomMessageFor(
MatrixUser(A_SESSION_ID, A_SESSION_ID.value, MY_AVATAR_URL), MatrixUser(A_SESSION_ID, A_SESSION_ID.value, MY_AVATAR_URL),
withRedactedRemoved, withRedactedRemoved,
A_ROOM_ID, A_ROOM_ID,

View file

@ -22,8 +22,8 @@ import io.element.android.libraries.matrix.test.AN_EVENT_ID
import io.element.android.libraries.matrix.test.A_ROOM_ID import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.matrix.test.A_SESSION_ID import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.push.impl.notifications.fake.FakeImageLoader import io.element.android.libraries.push.impl.notifications.fake.FakeImageLoader
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationDisplayer import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationDisplayer
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationFactory import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationFactory
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
import io.mockk.mockk import io.mockk.mockk
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
@ -51,14 +51,14 @@ private val ONE_SHOT_META = OneShotNotification.Append.Meta(key = "ignored", sum
@RunWith(RobolectricTestRunner::class) @RunWith(RobolectricTestRunner::class)
class NotificationRendererTest { class NotificationRendererTest {
private val notificationDisplayer = FakeNotificationDisplayer() private val mockkNotificationDisplayer = MockkNotificationDisplayer()
private val notificationFactory = FakeNotificationFactory() private val mockkNotificationFactory = MockkNotificationFactory()
private val notificationIdProvider = NotificationIdProvider() private val notificationIdProvider = NotificationIdProvider()
private val notificationRenderer = NotificationRenderer( private val notificationRenderer = NotificationRenderer(
notificationIdProvider = notificationIdProvider, notificationIdProvider = notificationIdProvider,
notificationDisplayer = notificationDisplayer.instance, notificationDisplayer = mockkNotificationDisplayer.instance,
notificationFactory = notificationFactory.instance, notificationFactory = mockkNotificationFactory.instance,
) )
@Test @Test
@ -67,8 +67,8 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifySummaryCancelled() mockkNotificationDisplayer.verifySummaryCancelled()
notificationDisplayer.verifyNoOtherInteractions() mockkNotificationDisplayer.verifyNoOtherInteractions()
} }
@Test @Test
@ -77,7 +77,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
cancelNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID))
cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID))
} }
@ -89,7 +89,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID))
showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification) showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification)
} }
@ -108,7 +108,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
showNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID), A_NOTIFICATION) showNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomMessagesNotificationId(A_SESSION_ID), A_NOTIFICATION)
showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification) showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification)
} }
@ -120,7 +120,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
cancelNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID))
cancelNotificationMessage(tag = AN_EVENT_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = AN_EVENT_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID))
} }
@ -132,7 +132,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
cancelNotificationMessage(tag = AN_EVENT_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = AN_EVENT_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID))
showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification) showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification)
} }
@ -151,7 +151,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
showNotificationMessage(tag = AN_EVENT_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID), A_NOTIFICATION) showNotificationMessage(tag = AN_EVENT_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID), A_NOTIFICATION)
showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification) showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification)
} }
@ -163,7 +163,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
cancelNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID))
cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomInvitationNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomInvitationNotificationId(A_SESSION_ID))
} }
@ -175,7 +175,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomInvitationNotificationId(A_SESSION_ID)) cancelNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomInvitationNotificationId(A_SESSION_ID))
showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification) showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification)
} }
@ -194,7 +194,7 @@ class NotificationRendererTest {
renderEventsAsNotifications() renderEventsAsNotifications()
notificationDisplayer.verifyInOrder { mockkNotificationDisplayer.verifyInOrder {
showNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID), A_NOTIFICATION) showNotificationMessage(tag = A_ROOM_ID.value, notificationIdProvider.getRoomEventNotificationId(A_SESSION_ID), A_NOTIFICATION)
showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification) showNotificationMessage(tag = null, notificationIdProvider.getSummaryNotificationId(A_SESSION_ID), A_SUMMARY_NOTIFICATION.notification)
} }
@ -221,7 +221,7 @@ class NotificationRendererTest {
useCompleteNotificationFormat: Boolean = USE_COMPLETE_NOTIFICATION_FORMAT, useCompleteNotificationFormat: Boolean = USE_COMPLETE_NOTIFICATION_FORMAT,
summaryNotification: SummaryNotification = A_SUMMARY_NOTIFICATION summaryNotification: SummaryNotification = A_SUMMARY_NOTIFICATION
) { ) {
notificationFactory.givenNotificationsFor( mockkNotificationFactory.givenNotificationsFor(
groupedEvents = A_PROCESSED_EVENTS, groupedEvents = A_PROCESSED_EVENTS,
matrixUser = MatrixUser(A_SESSION_ID, MY_USER_DISPLAY_NAME, MY_USER_AVATAR_URL), matrixUser = MatrixUser(A_SESSION_ID, MY_USER_DISPLAY_NAME, MY_USER_AVATAR_URL),
useCompleteNotificationFormat = useCompleteNotificationFormat, useCompleteNotificationFormat = useCompleteNotificationFormat,

View file

@ -23,7 +23,7 @@ import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiab
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
class FakeNotificationCreator { class MockkNotificationCreator {
val instance = mockk<NotificationCreator>() val instance = mockk<NotificationCreator>()
fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification { fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification {

View file

@ -25,7 +25,7 @@ import io.mockk.mockk
import io.mockk.verify import io.mockk.verify
import io.mockk.verifyOrder import io.mockk.verifyOrder
class FakeNotificationDisplayer { class MockkNotificationDisplayer {
val instance = mockk<NotificationDisplayer>(relaxed = true) val instance = mockk<NotificationDisplayer>(relaxed = true)
fun givenDisplayDiagnosticNotificationResult(result: Boolean) { fun givenDisplayDiagnosticNotificationResult(result: Boolean) {

View file

@ -26,7 +26,7 @@ import io.mockk.coEvery
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
class FakeNotificationFactory { class MockkNotificationFactory {
val instance = mockk<NotificationFactory>() val instance = mockk<NotificationFactory>()
fun givenNotificationsFor( fun givenNotificationsFor(

View file

@ -21,7 +21,7 @@ import io.element.android.libraries.push.impl.notifications.model.NotifiableEven
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
class FakeOutdatedEventDetector { class MockkOutdatedEventDetector {
val instance = mockk<OutdatedEventDetector>() val instance = mockk<OutdatedEventDetector>()
fun givenEventIsOutOfDate(notifiableEvent: NotifiableEvent) { fun givenEventIsOutOfDate(notifiableEvent: NotifiableEvent) {

View file

@ -24,7 +24,7 @@ import io.element.android.libraries.push.impl.notifications.model.NotifiableMess
import io.mockk.coEvery import io.mockk.coEvery
import io.mockk.mockk import io.mockk.mockk
class FakeRoomGroupMessageCreator { class MockkRoomGroupMessageCreator {
val instance = mockk<RoomGroupMessageCreator>() val instance = mockk<RoomGroupMessageCreator>()
fun givenCreatesRoomMessageFor( fun givenCreatesRoomMessageFor(

View file

@ -19,6 +19,6 @@ package io.element.android.libraries.push.impl.notifications.fake
import io.element.android.libraries.push.impl.notifications.SummaryGroupMessageCreator import io.element.android.libraries.push.impl.notifications.SummaryGroupMessageCreator
import io.mockk.mockk import io.mockk.mockk
class FakeSummaryGroupMessageCreator { class MockkSummaryGroupMessageCreator {
val instance = mockk<SummaryGroupMessageCreator>() val instance = mockk<SummaryGroupMessageCreator>()
} }

View file

@ -19,17 +19,17 @@ package io.element.android.libraries.push.impl.troubleshoot
import app.cash.turbine.test import app.cash.turbine.test
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState import io.element.android.libraries.core.notifications.NotificationTroubleshootTestState
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationCreator import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationCreator
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationDisplayer import io.element.android.libraries.push.impl.notifications.fake.MockkNotificationDisplayer
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.Test import org.junit.Test
class NotificationTestTest { class NotificationTestTest {
private val fakeNotificationCreator = FakeNotificationCreator().apply { private val mockkNotificationCreator = MockkNotificationCreator().apply {
givenCreateDiagnosticNotification() givenCreateDiagnosticNotification()
} }
private val fakeNotificationDisplayer = FakeNotificationDisplayer().apply { private val mockkNotificationDisplayer = MockkNotificationDisplayer().apply {
givenDisplayDiagnosticNotificationResult(true) givenDisplayDiagnosticNotificationResult(true)
} }
@ -37,7 +37,7 @@ class NotificationTestTest {
@Test @Test
fun `test NotificationTest notification cannot be displayed`() = runTest { fun `test NotificationTest notification cannot be displayed`() = runTest {
fakeNotificationDisplayer.givenDisplayDiagnosticNotificationResult(false) mockkNotificationDisplayer.givenDisplayDiagnosticNotificationResult(false)
val sut = createNotificationTest() val sut = createNotificationTest()
launch { launch {
sut.run(this) sut.run(this)
@ -80,8 +80,8 @@ class NotificationTestTest {
private fun createNotificationTest(): NotificationTest { private fun createNotificationTest(): NotificationTest {
return NotificationTest( return NotificationTest(
notificationCreator = fakeNotificationCreator.instance, notificationCreator = mockkNotificationCreator.instance,
notificationDisplayer = fakeNotificationDisplayer.instance, notificationDisplayer = mockkNotificationDisplayer.instance,
notificationClickHandler = notificationClickHandler notificationClickHandler = notificationClickHandler
) )
} }