From ae7137bd1da82bd016e22f33d438dd7276f779f4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 17 Apr 2023 09:51:52 +0200 Subject: [PATCH] Fix tests. --- .../impl/notifications/NotificationFactoryTest.kt | 10 +++++----- ...nUtils.kt => FakeAndroidNotificationFactory.kt} | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) rename libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/{FakeNotificationUtils.kt => FakeAndroidNotificationFactory.kt} (66%) diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/NotificationFactoryTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/NotificationFactoryTest.kt index 606923eb1f..7cc9479ee9 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/NotificationFactoryTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/NotificationFactoryTest.kt @@ -21,7 +21,7 @@ import io.element.android.libraries.matrix.api.core.EventId 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_SESSION_ID -import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationUtils +import io.element.android.libraries.push.impl.notifications.fake.FakeAndroidNotificationFactory import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent @@ -36,19 +36,19 @@ private val A_MESSAGE_EVENT = aNotifiableMessageEvent(eventId = AN_EVENT_ID, roo class NotificationFactoryTest { - private val notificationUtils = FakeNotificationUtils() + private val androidNotificationFactory = FakeAndroidNotificationFactory() private val roomGroupMessageCreator = FakeRoomGroupMessageCreator() private val summaryGroupMessageCreator = FakeSummaryGroupMessageCreator() private val notificationFactory = NotificationFactory( - notificationUtils.instance, + androidNotificationFactory.instance, roomGroupMessageCreator.instance, summaryGroupMessageCreator.instance ) @Test fun `given a room invitation when mapping to notification then is Append`() = testWith(notificationFactory) { - val expectedNotification = notificationUtils.givenBuildRoomInvitationNotificationFor(AN_INVITATION_EVENT) + val expectedNotification = androidNotificationFactory.givenCreateRoomInvitationNotificationFor(AN_INVITATION_EVENT) val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, AN_INVITATION_EVENT)) val result = roomInvitation.toNotifications() @@ -85,7 +85,7 @@ class NotificationFactoryTest { @Test fun `given a simple event when mapping to notification then is Append`() = testWith(notificationFactory) { - val expectedNotification = notificationUtils.givenBuildSimpleInvitationNotificationFor(A_SIMPLE_EVENT) + val expectedNotification = androidNotificationFactory.givenCreateSimpleInvitationNotificationFor(A_SIMPLE_EVENT) val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, A_SIMPLE_EVENT)) val result = roomInvitation.toNotifications() diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationUtils.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeAndroidNotificationFactory.kt similarity index 66% rename from libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationUtils.kt rename to libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeAndroidNotificationFactory.kt index 046b2edd87..c046e1253f 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeNotificationUtils.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/notifications/fake/FakeAndroidNotificationFactory.kt @@ -17,24 +17,24 @@ package io.element.android.libraries.push.impl.notifications.fake import android.app.Notification -import io.element.android.libraries.push.impl.notifications.NotificationUtils +import io.element.android.libraries.push.impl.notifications.factories.NotificationFactory import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent import io.mockk.every import io.mockk.mockk -class FakeNotificationUtils { - val instance = mockk() +class FakeAndroidNotificationFactory { + val instance = mockk() - fun givenBuildRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification { + fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification { val mockNotification = mockk() - every { instance.buildRoomInvitationNotification(event) } returns mockNotification + every { instance.createRoomInvitationNotification(event) } returns mockNotification return mockNotification } - fun givenBuildSimpleInvitationNotificationFor(event: SimpleNotifiableEvent): Notification { + fun givenCreateSimpleInvitationNotificationFor(event: SimpleNotifiableEvent): Notification { val mockNotification = mockk() - every { instance.buildSimpleEventNotification(event) } returns mockNotification + every { instance.createSimpleEventNotification(event) } returns mockNotification return mockNotification } }