Skip to content

Commit

Permalink
feat: base for system msg creator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilmedina committed Oct 23, 2023
1 parent 7c16198 commit 68651de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ internal class NewConversationEventHandlerImpl(
event.conversation
)
newGroupConversationSystemMessagesCreator.conversationReadReceiptStatus(event.conversation)
newGroupConversationSystemMessagesCreator.conversationStartedUnverifiedWarning(event.conversation.id.toModel())
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class NewConversationEventHandlerTest {
.withFetchUsersIfUnknownIds(members)
.withSelfUserTeamId(Either.Right(teamId))
.withConversationStartedSystemMessage()
.withConversationUnverifiedWarningSystemMessage()
.withConversationResolvedMembersSystemMessage()
.withReadReceiptsSystemMessage()
.withQualifiedId(creatorQualifiedId)
Expand All @@ -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,
Expand All @@ -124,6 +125,7 @@ class NewConversationEventHandlerTest {
.withFetchUsersIfUnknownIds(members)
.withSelfUserTeamId(Either.Right(teamId))
.withConversationStartedSystemMessage()
.withConversationUnverifiedWarningSystemMessage()
.withConversationResolvedMembersSystemMessage()
.withReadReceiptsSystemMessage()
.withQualifiedId(creatorQualifiedId)
Expand Down Expand Up @@ -167,6 +169,7 @@ class NewConversationEventHandlerTest {
.withSelfUserTeamId(Either.Right(teamId))
.withConversationStartedSystemMessage()
.withConversationResolvedMembersSystemMessage()
.withConversationUnverifiedWarningSystemMessage()
.withReadReceiptsSystemMessage()
.withQualifiedId(creatorQualifiedId)
.arrange()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<QualifiedID>) = apply {
given(userRepository)
.suspendFunction(userRepository::fetchUsersIfUnknownByIds)
Expand Down

0 comments on commit 68651de

Please sign in to comment.