From 5011649499a1e7fc406670683efe936bb6e15753 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Mon, 2 Dec 2024 15:25:15 +0100 Subject: [PATCH] fix(detekt): shorten test method by extracting conversation object creation Signed-off-by: Andy Scherzinger --- .../talk/utils/ParticipantPermissionsTest.kt | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/app/src/test/java/com/nextcloud/talk/utils/ParticipantPermissionsTest.kt b/app/src/test/java/com/nextcloud/talk/utils/ParticipantPermissionsTest.kt index 0e39963f71..239b2264b2 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/ParticipantPermissionsTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/ParticipantPermissionsTest.kt @@ -21,7 +21,34 @@ class ParticipantPermissionsTest : TestCase() { @Test fun test_areFlagsSet() { val spreedCapability = SpreedCapability() - val conversation = Conversation( + val conversation = createConversation() + + conversation.permissions = ParticipantPermissions.PUBLISH_SCREEN or + ParticipantPermissions.JOIN_CALL or + ParticipantPermissions.DEFAULT + + val user = User() + user.id = 1 + + val attendeePermissions = + ParticipantPermissions( + spreedCapability, + ConversationModel.mapToConversationModel(conversation, user) + ) + + assert(attendeePermissions.canPublishScreen) + assert(attendeePermissions.canJoinCall) + assert(attendeePermissions.isDefault) + + assertFalse(attendeePermissions.isCustom) + assertFalse(attendeePermissions.canStartCall()) + assertFalse(attendeePermissions.canIgnoreLobby()) + assertTrue(attendeePermissions.canPublishAudio()) + assertTrue(attendeePermissions.canPublishVideo()) + } + + private fun createConversation(): Conversation { + return Conversation( token = "test", name = "test", displayName = "test", @@ -67,28 +94,5 @@ class ParticipantPermissionsTest : TestCase() { remoteServer = "", remoteToken = "" ) - - conversation.permissions = ParticipantPermissions.PUBLISH_SCREEN or - ParticipantPermissions.JOIN_CALL or - ParticipantPermissions.DEFAULT - - val user = User() - user.id = 1 - - val attendeePermissions = - ParticipantPermissions( - spreedCapability, - ConversationModel.mapToConversationModel(conversation, user) - ) - - assert(attendeePermissions.canPublishScreen) - assert(attendeePermissions.canJoinCall) - assert(attendeePermissions.isDefault) - - assertFalse(attendeePermissions.isCustom) - assertFalse(attendeePermissions.canStartCall()) - assertFalse(attendeePermissions.canIgnoreLobby()) - assertTrue(attendeePermissions.canPublishAudio()) - assertTrue(attendeePermissions.canPublishVideo()) } }