-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add useSFTForOneToOneCalls flag (WPB-7153) 🍒 (#2892)
* feat: add useSFTForOneToOneCalls flag (WPB-7153) (#2889) * feat: add useSFTForOneToOneCalls flag * chore: uni test * chore: unit test * chore: Empty-Commit --------- Co-authored-by: Oussama Hassine <[email protected]>
- Loading branch information
1 parent
69d3227
commit 5707160
Showing
15 changed files
with
221 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
...com/wire/kalium/logic/feature/featureConfig/handler/ConferenceCallingConfigHandlerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
/* | ||
* Wire | ||
* Copyright (C) 2024 Wire Swiss GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
package com.wire.kalium.logic.feature.featureConfig.handler | ||
|
||
import com.wire.kalium.logic.StorageFailure | ||
import com.wire.kalium.logic.configuration.UserConfigRepository | ||
import com.wire.kalium.logic.data.featureConfig.ConferenceCallingModel | ||
import com.wire.kalium.logic.data.featureConfig.Status | ||
import com.wire.kalium.logic.functional.Either | ||
import com.wire.kalium.logic.functional.isLeft | ||
import com.wire.kalium.logic.functional.isRight | ||
import io.mockative.Mock | ||
import io.mockative.any | ||
import io.mockative.every | ||
import io.mockative.mock | ||
import io.mockative.once | ||
import io.mockative.verify | ||
import kotlin.test.Test | ||
import kotlin.test.assertTrue | ||
|
||
class ConferenceCallingConfigHandlerTest { | ||
|
||
@Test | ||
fun givenUserConfigRepositoryFailureForConferenceCallingEnabled_whenHandlingTheEvent_ThenReturnFailure() { | ||
val conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false) | ||
val (arrangement, conferenceCallingConfigHandler) = Arrangement() | ||
.withSetConferenceCallingEnabledFailure() | ||
.arrange() | ||
|
||
val result = conferenceCallingConfigHandler.handle(conferenceCallingModel) | ||
|
||
verify { | ||
arrangement.userConfigRepository.setConferenceCallingEnabled(conferenceCallingModel.status.toBoolean()) | ||
}.wasInvoked(exactly = once) | ||
|
||
verify { | ||
arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(any()) | ||
}.wasNotInvoked() | ||
|
||
assertTrue { result.isLeft() } | ||
} | ||
|
||
@Test | ||
fun givenUserConfigRepositoryFailureForUseSFTForOneOnOneCalls_whenHandlingTheEvent_ThenReturnFailure() { | ||
val conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false) | ||
val (arrangement, conferenceCallingConfigHandler) = Arrangement() | ||
.withSetConferenceCallingEnabledSuccess() | ||
.withSetUseSFTForOneOnOneCallsFailure() | ||
.arrange() | ||
|
||
val result = conferenceCallingConfigHandler.handle(conferenceCallingModel) | ||
|
||
verify { | ||
arrangement.userConfigRepository.setConferenceCallingEnabled(conferenceCallingModel.status.toBoolean()) | ||
}.wasInvoked(exactly = once) | ||
|
||
verify { | ||
arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(any()) | ||
}.wasInvoked(exactly = once) | ||
|
||
assertTrue { result.isLeft() } | ||
} | ||
|
||
@Test | ||
fun givenUserConfigRepositorySuccess_whenHandlingTheEvent_ThenReturnUnit() { | ||
val conferenceCallingModel = ConferenceCallingModel(Status.ENABLED, false) | ||
val (arrangement, conferenceCallingConfigHandler) = Arrangement() | ||
.withSetConferenceCallingEnabledSuccess() | ||
.withSetUseSFTForOneOnOneCallsSuccess() | ||
.arrange() | ||
|
||
val result = conferenceCallingConfigHandler.handle(conferenceCallingModel) | ||
|
||
verify { | ||
arrangement.userConfigRepository.setConferenceCallingEnabled(conferenceCallingModel.status.toBoolean()) | ||
}.wasInvoked(exactly = once) | ||
|
||
verify { | ||
arrangement.userConfigRepository.setUseSFTForOneOnOneCalls(any()) | ||
}.wasInvoked(exactly = once) | ||
|
||
assertTrue { result.isRight() } | ||
} | ||
|
||
private class Arrangement { | ||
|
||
@Mock | ||
val userConfigRepository: UserConfigRepository = mock(UserConfigRepository::class) | ||
|
||
fun arrange() = run { | ||
this@Arrangement to ConferenceCallingConfigHandler( | ||
userConfigRepository = userConfigRepository | ||
) | ||
} | ||
|
||
init { | ||
every { | ||
userConfigRepository.setAppLockStatus(any(), any(), any()) | ||
}.returns(Either.Right(Unit)) | ||
} | ||
|
||
fun withSetConferenceCallingEnabledFailure() = apply { | ||
every { | ||
userConfigRepository.setConferenceCallingEnabled(any()) | ||
}.returns(Either.Left(StorageFailure.DataNotFound)) | ||
} | ||
|
||
fun withSetConferenceCallingEnabledSuccess() = apply { | ||
every { | ||
userConfigRepository.setConferenceCallingEnabled(any()) | ||
}.returns(Either.Right(Unit)) | ||
} | ||
|
||
fun withSetUseSFTForOneOnOneCallsFailure() = apply { | ||
every { | ||
userConfigRepository.setUseSFTForOneOnOneCalls(any()) | ||
}.returns(Either.Left(StorageFailure.DataNotFound)) | ||
} | ||
|
||
fun withSetUseSFTForOneOnOneCallsSuccess() = apply { | ||
every { | ||
userConfigRepository.setUseSFTForOneOnOneCalls(any()) | ||
}.returns(Either.Right(Unit)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.