From 68651de6ebea8838a79816c7c5ad21ff479bf644 Mon Sep 17 00:00:00 2001 From: yamilmedina Date: Mon, 23 Oct 2023 14:43:44 +0200 Subject: [PATCH] feat: base for system msg creator tests --- .../AcceptConnectionRequestUseCase.kt | 2 +- .../conversation/NewConversationEventHandler.kt | 1 + .../NewConversationEventHandlerTest.kt | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/connection/AcceptConnectionRequestUseCase.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/connection/AcceptConnectionRequestUseCase.kt index 7b332ac47f3..75569d285bf 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/connection/AcceptConnectionRequestUseCase.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/connection/AcceptConnectionRequestUseCase.kt @@ -33,7 +33,7 @@ import com.wire.kalium.util.DateTimeUtil /** * Use Case that allows a user accept a connection request to connect with another User */ -fun interface AcceptConnectionRequestUseCase { +interface AcceptConnectionRequestUseCase { /** * Use case [AcceptConnectionRequestUseCase] operation * diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt index 367b7916cec..8dc1fbf0f14 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt @@ -81,6 +81,7 @@ internal class NewConversationEventHandlerImpl( event.conversation ) newGroupConversationSystemMessagesCreator.conversationReadReceiptStatus(event.conversation) + newGroupConversationSystemMessagesCreator.conversationStartedUnverifiedWarning(event.conversation.id.toModel()) } } } diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandlerTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandlerTest.kt index 6360cfd7bc7..c112debd0a3 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandlerTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandlerTest.kt @@ -81,6 +81,7 @@ class NewConversationEventHandlerTest { .withFetchUsersIfUnknownIds(members) .withSelfUserTeamId(Either.Right(teamId)) .withConversationStartedSystemMessage() + .withConversationUnverifiedWarningSystemMessage() .withConversationResolvedMembersSystemMessage() .withReadReceiptsSystemMessage() .withQualifiedId(creatorQualifiedId) @@ -104,7 +105,7 @@ class NewConversationEventHandlerTest { val event = Event.Conversation.NewConversation( id = "eventId", conversationId = TestConversation.ID, - transient =false, + transient = false, live = false, timestampIso = "timestamp", conversation = TestConversation.CONVERSATION_RESPONSE, @@ -124,6 +125,7 @@ class NewConversationEventHandlerTest { .withFetchUsersIfUnknownIds(members) .withSelfUserTeamId(Either.Right(teamId)) .withConversationStartedSystemMessage() + .withConversationUnverifiedWarningSystemMessage() .withConversationResolvedMembersSystemMessage() .withReadReceiptsSystemMessage() .withQualifiedId(creatorQualifiedId) @@ -167,6 +169,7 @@ class NewConversationEventHandlerTest { .withSelfUserTeamId(Either.Right(teamId)) .withConversationStartedSystemMessage() .withConversationResolvedMembersSystemMessage() + .withConversationUnverifiedWarningSystemMessage() .withReadReceiptsSystemMessage() .withQualifiedId(creatorQualifiedId) .arrange() @@ -195,6 +198,11 @@ class NewConversationEventHandlerTest { ) .with(eq(event.conversation)) .wasInvoked(exactly = once) + + verify(arrangement.newGroupConversationSystemMessagesCreator) + .suspendFunction(arrangement.newGroupConversationSystemMessagesCreator::conversationStartedUnverifiedWarning) + .with(eq(event.conversation.id.toModel())) + .wasInvoked(exactly = once) } @Test @@ -315,6 +323,13 @@ class NewConversationEventHandlerTest { .thenReturn(Either.Right(Unit)) } + fun withConversationUnverifiedWarningSystemMessage() = apply { + given(newGroupConversationSystemMessagesCreator) + .suspendFunction(newGroupConversationSystemMessagesCreator::conversationStartedUnverifiedWarning) + .whenInvokedWith(any()) + .thenReturn(Either.Right(Unit)) + } + suspend fun withFetchUsersIfUnknownIds(members: Set) = apply { given(userRepository) .suspendFunction(userRepository::fetchUsersIfUnknownByIds)