Browse Source

Rename class (code quality)

pull/2900/head
Benoit Marty 4 months ago
parent
commit
7911fda1fa
  1. 12
      appnav/src/test/kotlin/io/element/android/appnav/di/MatrixClientsHolderTest.kt
  2. 4
      features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/unlock/DefaultSignOutTest.kt
  3. 8
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/changeserver/ChangeServerPresenterTest.kt
  4. 14
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/oidc/webview/OidcPresenterTest.kt
  5. 4
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/changeaccountprovider/ChangeAccountProviderPresenterTest.kt
  6. 20
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenterTest.kt
  7. 12
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordPresenterTest.kt
  8. 12
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/searchaccountprovider/SearchAccountProviderPresenterTest.kt
  9. 8
      features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/waitlistscreen/WaitListPresenterTest.kt
  10. 2
      libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/auth/FakeMatrixAuthenticationService.kt
  11. 8
      libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt
  12. 10
      libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/DefaultFirebaseNewTokenHandlerTest.kt
  13. 8
      libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/DefaultUnifiedPushNewGatewayHandlerTest.kt

12
appnav/src/test/kotlin/io/element/android/appnav/di/MatrixClientsHolderTest.kt

@ -20,21 +20,21 @@ import com.bumble.appyx.core.state.MutableSavedStateMapImpl @@ -20,21 +20,21 @@ import com.bumble.appyx.core.state.MutableSavedStateMapImpl
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.matrix.test.FakeMatrixClient
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import kotlinx.coroutines.test.runTest
import org.junit.Test
class MatrixClientsHolderTest {
@Test
fun `test getOrNull`() {
val fakeAuthenticationService = FakeAuthenticationService()
val fakeAuthenticationService = FakeMatrixAuthenticationService()
val matrixClientsHolder = MatrixClientsHolder(fakeAuthenticationService)
assertThat(matrixClientsHolder.getOrNull(A_SESSION_ID)).isNull()
}
@Test
fun `test getOrRestore`() = runTest {
val fakeAuthenticationService = FakeAuthenticationService()
val fakeAuthenticationService = FakeMatrixAuthenticationService()
val matrixClientsHolder = MatrixClientsHolder(fakeAuthenticationService)
val fakeMatrixClient = FakeMatrixClient()
fakeAuthenticationService.givenMatrixClient(fakeMatrixClient)
@ -47,7 +47,7 @@ class MatrixClientsHolderTest { @@ -47,7 +47,7 @@ class MatrixClientsHolderTest {
@Test
fun `test remove`() = runTest {
val fakeAuthenticationService = FakeAuthenticationService()
val fakeAuthenticationService = FakeMatrixAuthenticationService()
val matrixClientsHolder = MatrixClientsHolder(fakeAuthenticationService)
val fakeMatrixClient = FakeMatrixClient()
fakeAuthenticationService.givenMatrixClient(fakeMatrixClient)
@ -60,7 +60,7 @@ class MatrixClientsHolderTest { @@ -60,7 +60,7 @@ class MatrixClientsHolderTest {
@Test
fun `test remove all`() = runTest {
val fakeAuthenticationService = FakeAuthenticationService()
val fakeAuthenticationService = FakeMatrixAuthenticationService()
val matrixClientsHolder = MatrixClientsHolder(fakeAuthenticationService)
val fakeMatrixClient = FakeMatrixClient()
fakeAuthenticationService.givenMatrixClient(fakeMatrixClient)
@ -73,7 +73,7 @@ class MatrixClientsHolderTest { @@ -73,7 +73,7 @@ class MatrixClientsHolderTest {
@Test
fun `test save and restore`() = runTest {
val fakeAuthenticationService = FakeAuthenticationService()
val fakeAuthenticationService = FakeMatrixAuthenticationService()
val matrixClientsHolder = MatrixClientsHolder(fakeAuthenticationService)
val fakeMatrixClient = FakeMatrixClient()
fakeAuthenticationService.givenMatrixClient(fakeMatrixClient)

4
features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/unlock/DefaultSignOutTest.kt

@ -20,7 +20,7 @@ import com.google.common.truth.Truth.assertThat @@ -20,7 +20,7 @@ import com.google.common.truth.Truth.assertThat
import io.element.android.features.lockscreen.impl.unlock.signout.DefaultSignOut
import io.element.android.libraries.matrix.test.FakeMatrixClient
import io.element.android.libraries.matrix.test.FakeMatrixClientProvider
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.lambda.assert
import io.element.android.tests.testutils.lambda.lambdaRecorder
import kotlinx.coroutines.test.runTest
@ -28,7 +28,7 @@ import org.junit.Test @@ -28,7 +28,7 @@ import org.junit.Test
class DefaultSignOutTest {
private val matrixClient = FakeMatrixClient()
private val authenticationService = FakeAuthenticationService()
private val authenticationService = FakeMatrixAuthenticationService()
private val matrixClientProvider = FakeMatrixClientProvider(getClient = { Result.success(matrixClient) })
private val sut = DefaultSignOut(authenticationService, matrixClientProvider)

8
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/changeserver/ChangeServerPresenterTest.kt

@ -25,7 +25,7 @@ import io.element.android.features.login.impl.accountprovider.AccountProviderDat @@ -25,7 +25,7 @@ import io.element.android.features.login.impl.accountprovider.AccountProviderDat
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.matrix.test.A_HOMESERVER
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.WarmUpRule
import kotlinx.coroutines.test.runTest
import org.junit.Rule
@ -38,7 +38,7 @@ class ChangeServerPresenterTest { @@ -38,7 +38,7 @@ class ChangeServerPresenterTest {
@Test
fun `present - initial state`() = runTest {
val presenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
moleculeFlow(RecompositionMode.Immediate) {
@ -51,7 +51,7 @@ class ChangeServerPresenterTest { @@ -51,7 +51,7 @@ class ChangeServerPresenterTest {
@Test
fun `present - change server ok`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = ChangeServerPresenter(
authenticationService,
AccountProviderDataSource()
@ -72,7 +72,7 @@ class ChangeServerPresenterTest { @@ -72,7 +72,7 @@ class ChangeServerPresenterTest {
@Test
fun `present - change server error`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = ChangeServerPresenter(
authenticationService,
AccountProviderDataSource()

14
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/oidc/webview/OidcPresenterTest.kt

@ -26,7 +26,7 @@ import io.element.android.features.login.api.oidc.OidcAction @@ -26,7 +26,7 @@ import io.element.android.features.login.api.oidc.OidcAction
import io.element.android.libraries.architecture.AsyncAction
import io.element.android.libraries.matrix.test.A_THROWABLE
import io.element.android.libraries.matrix.test.auth.A_OIDC_DATA
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.WarmUpRule
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
@ -41,7 +41,7 @@ class OidcPresenterTest { @@ -41,7 +41,7 @@ class OidcPresenterTest {
fun `present - initial state`() = runTest {
val presenter = OidcPresenter(
A_OIDC_DATA,
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
)
moleculeFlow(RecompositionMode.Immediate) {
presenter.present()
@ -56,7 +56,7 @@ class OidcPresenterTest { @@ -56,7 +56,7 @@ class OidcPresenterTest {
fun `present - go back`() = runTest {
val presenter = OidcPresenter(
A_OIDC_DATA,
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
)
moleculeFlow(RecompositionMode.Immediate) {
presenter.present()
@ -72,7 +72,7 @@ class OidcPresenterTest { @@ -72,7 +72,7 @@ class OidcPresenterTest {
@Test
fun `present - go back with failure`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = OidcPresenter(
A_OIDC_DATA,
authenticationService,
@ -95,7 +95,7 @@ class OidcPresenterTest { @@ -95,7 +95,7 @@ class OidcPresenterTest {
fun `present - user cancels from webview`() = runTest {
val presenter = OidcPresenter(
A_OIDC_DATA,
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
)
moleculeFlow(RecompositionMode.Immediate) {
presenter.present()
@ -113,7 +113,7 @@ class OidcPresenterTest { @@ -113,7 +113,7 @@ class OidcPresenterTest {
fun `present - login success`() = runTest {
val presenter = OidcPresenter(
A_OIDC_DATA,
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
)
moleculeFlow(RecompositionMode.Immediate) {
presenter.present()
@ -128,7 +128,7 @@ class OidcPresenterTest { @@ -128,7 +128,7 @@ class OidcPresenterTest {
@Test
fun `present - login error`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = OidcPresenter(
A_OIDC_DATA,
authenticationService,

4
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/changeaccountprovider/ChangeAccountProviderPresenterTest.kt

@ -23,7 +23,7 @@ import com.google.common.truth.Truth.assertThat @@ -23,7 +23,7 @@ import com.google.common.truth.Truth.assertThat
import io.element.android.features.login.impl.accountprovider.AccountProvider
import io.element.android.features.login.impl.accountprovider.AccountProviderDataSource
import io.element.android.features.login.impl.changeserver.ChangeServerPresenter
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.WarmUpRule
import kotlinx.coroutines.test.runTest
import org.junit.Rule
@ -36,7 +36,7 @@ class ChangeAccountProviderPresenterTest { @@ -36,7 +36,7 @@ class ChangeAccountProviderPresenterTest {
@Test
fun `present - initial state`() = runTest {
val changeServerPresenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
val presenter = ChangeAccountProviderPresenter(

20
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/confirmaccountprovider/ConfirmAccountProviderPresenterTest.kt

@ -30,7 +30,7 @@ import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService @@ -30,7 +30,7 @@ import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
import io.element.android.libraries.matrix.test.A_HOMESERVER
import io.element.android.libraries.matrix.test.A_HOMESERVER_OIDC
import io.element.android.libraries.matrix.test.A_THROWABLE
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.WarmUpRule
import io.element.android.tests.testutils.waitForPredicate
import kotlinx.coroutines.test.runTest
@ -57,7 +57,7 @@ class ConfirmAccountProviderPresenterTest { @@ -57,7 +57,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - continue password login`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
)
@ -79,7 +79,7 @@ class ConfirmAccountProviderPresenterTest { @@ -79,7 +79,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - continue oidc`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
)
@ -101,7 +101,7 @@ class ConfirmAccountProviderPresenterTest { @@ -101,7 +101,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - oidc - cancel with failure`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val defaultOidcActionFlow = DefaultOidcActionFlow()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
@ -129,7 +129,7 @@ class ConfirmAccountProviderPresenterTest { @@ -129,7 +129,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - oidc - cancel with success`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val defaultOidcActionFlow = DefaultOidcActionFlow()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
@ -156,7 +156,7 @@ class ConfirmAccountProviderPresenterTest { @@ -156,7 +156,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - oidc - success with failure`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val defaultOidcActionFlow = DefaultOidcActionFlow()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
@ -186,7 +186,7 @@ class ConfirmAccountProviderPresenterTest { @@ -186,7 +186,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - oidc - success with success`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val defaultOidcActionFlow = DefaultOidcActionFlow()
val defaultLoginUserStory = DefaultLoginUserStory().apply {
setLoginFlowIsDone(false)
@ -219,7 +219,7 @@ class ConfirmAccountProviderPresenterTest { @@ -219,7 +219,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - submit fails`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
)
@ -238,7 +238,7 @@ class ConfirmAccountProviderPresenterTest { @@ -238,7 +238,7 @@ class ConfirmAccountProviderPresenterTest {
@Test
fun `present - clear error`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val presenter = createConfirmAccountProviderPresenter(
matrixAuthenticationService = authenticationService,
)
@ -267,7 +267,7 @@ class ConfirmAccountProviderPresenterTest { @@ -267,7 +267,7 @@ class ConfirmAccountProviderPresenterTest {
private fun createConfirmAccountProviderPresenter(
params: ConfirmAccountProviderPresenter.Params = ConfirmAccountProviderPresenter.Params(isAccountCreation = false),
accountProviderDataSource: AccountProviderDataSource = AccountProviderDataSource(),
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService(),
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
defaultOidcActionFlow: DefaultOidcActionFlow = DefaultOidcActionFlow(),
defaultLoginUserStory: DefaultLoginUserStory = DefaultLoginUserStory(),
) = ConfirmAccountProviderPresenter(

12
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordPresenterTest.kt

@ -30,7 +30,7 @@ import io.element.android.libraries.matrix.test.A_PASSWORD @@ -30,7 +30,7 @@ import io.element.android.libraries.matrix.test.A_PASSWORD
import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.matrix.test.A_THROWABLE
import io.element.android.libraries.matrix.test.A_USER_NAME
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.WarmUpRule
import kotlinx.coroutines.test.runTest
import org.junit.Rule
@ -42,7 +42,7 @@ class LoginPasswordPresenterTest { @@ -42,7 +42,7 @@ class LoginPasswordPresenterTest {
@Test
fun `present - initial state`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val accountProviderDataSource = AccountProviderDataSource()
val loginUserStory = DefaultLoginUserStory()
val presenter = LoginPasswordPresenter(
@ -63,7 +63,7 @@ class LoginPasswordPresenterTest { @@ -63,7 +63,7 @@ class LoginPasswordPresenterTest {
@Test
fun `present - enter login and password`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val accountProviderDataSource = AccountProviderDataSource()
val loginUserStory = DefaultLoginUserStory()
val presenter = LoginPasswordPresenter(
@ -89,7 +89,7 @@ class LoginPasswordPresenterTest { @@ -89,7 +89,7 @@ class LoginPasswordPresenterTest {
@Test
fun `present - submit`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val accountProviderDataSource = AccountProviderDataSource()
val loginUserStory = DefaultLoginUserStory().apply { setLoginFlowIsDone(false) }
val presenter = LoginPasswordPresenter(
@ -118,7 +118,7 @@ class LoginPasswordPresenterTest { @@ -118,7 +118,7 @@ class LoginPasswordPresenterTest {
@Test
fun `present - submit with error`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val accountProviderDataSource = AccountProviderDataSource()
val loginUserStory = DefaultLoginUserStory()
val presenter = LoginPasswordPresenter(
@ -146,7 +146,7 @@ class LoginPasswordPresenterTest { @@ -146,7 +146,7 @@ class LoginPasswordPresenterTest {
@Test
fun `present - clear error`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val accountProviderDataSource = AccountProviderDataSource()
val loginUserStory = DefaultLoginUserStory()
val presenter = LoginPasswordPresenter(

12
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/searchaccountprovider/SearchAccountProviderPresenterTest.kt

@ -29,7 +29,7 @@ import io.element.android.features.login.impl.resolver.network.WellKnownBaseConf @@ -29,7 +29,7 @@ import io.element.android.features.login.impl.resolver.network.WellKnownBaseConf
import io.element.android.features.login.impl.resolver.network.WellKnownSlidingSyncConfig
import io.element.android.libraries.architecture.AsyncData
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.tests.testutils.WarmUpRule
import io.element.android.tests.testutils.testCoroutineDispatchers
import kotlinx.coroutines.test.runTest
@ -44,7 +44,7 @@ class SearchAccountProviderPresenterTest { @@ -44,7 +44,7 @@ class SearchAccountProviderPresenterTest {
fun `present - initial state`() = runTest {
val fakeWellknownRequest = FakeWellknownRequest()
val changeServerPresenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
val presenter = SearchAccountProviderPresenter(
@ -64,7 +64,7 @@ class SearchAccountProviderPresenterTest { @@ -64,7 +64,7 @@ class SearchAccountProviderPresenterTest {
fun `present - enter text no result`() = runTest {
val fakeWellknownRequest = FakeWellknownRequest()
val changeServerPresenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
val presenter = SearchAccountProviderPresenter(
@ -88,7 +88,7 @@ class SearchAccountProviderPresenterTest { @@ -88,7 +88,7 @@ class SearchAccountProviderPresenterTest {
fun `present - enter valid url no wellknown`() = runTest {
val fakeWellknownRequest = FakeWellknownRequest()
val changeServerPresenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
val presenter = SearchAccountProviderPresenter(
@ -123,7 +123,7 @@ class SearchAccountProviderPresenterTest { @@ -123,7 +123,7 @@ class SearchAccountProviderPresenterTest {
)
)
val changeServerPresenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
val presenter = SearchAccountProviderPresenter(
@ -158,7 +158,7 @@ class SearchAccountProviderPresenterTest { @@ -158,7 +158,7 @@ class SearchAccountProviderPresenterTest {
)
)
val changeServerPresenter = ChangeServerPresenter(
FakeAuthenticationService(),
FakeMatrixAuthenticationService(),
AccountProviderDataSource()
)
val presenter = SearchAccountProviderPresenter(

8
features/login/impl/src/test/kotlin/io/element/android/features/login/impl/screens/waitlistscreen/WaitListPresenterTest.kt

@ -28,7 +28,7 @@ import io.element.android.libraries.matrix.test.A_HOMESERVER @@ -28,7 +28,7 @@ import io.element.android.libraries.matrix.test.A_HOMESERVER
import io.element.android.libraries.matrix.test.A_HOMESERVER_URL
import io.element.android.libraries.matrix.test.A_THROWABLE
import io.element.android.libraries.matrix.test.A_USER_ID
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.libraries.matrix.test.core.aBuildMeta
import io.element.android.tests.testutils.WarmUpRule
import kotlinx.coroutines.test.runTest
@ -41,7 +41,7 @@ class WaitListPresenterTest { @@ -41,7 +41,7 @@ class WaitListPresenterTest {
@Test
fun `present - initial state`() = runTest {
val authenticationService = FakeAuthenticationService().apply {
val authenticationService = FakeMatrixAuthenticationService().apply {
givenHomeserver(A_HOMESERVER)
}
val loginUserStory = DefaultLoginUserStory()
@ -63,7 +63,7 @@ class WaitListPresenterTest { @@ -63,7 +63,7 @@ class WaitListPresenterTest {
@Test
fun `present - attempt login with error`() = runTest {
val authenticationService = FakeAuthenticationService().apply {
val authenticationService = FakeMatrixAuthenticationService().apply {
givenLoginError(A_THROWABLE)
}
val loginUserStory = DefaultLoginUserStory()
@ -94,7 +94,7 @@ class WaitListPresenterTest { @@ -94,7 +94,7 @@ class WaitListPresenterTest {
@Test
fun `present - attempt login with success`() = runTest {
val authenticationService = FakeAuthenticationService()
val authenticationService = FakeMatrixAuthenticationService()
val loginUserStory = DefaultLoginUserStory().apply { setLoginFlowIsDone(false) }
val presenter = WaitListPresenter(
LoginFormState.Default,

2
libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/auth/FakeAuthenticationService.kt → libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/auth/FakeMatrixAuthenticationService.kt

@ -31,7 +31,7 @@ import kotlinx.coroutines.flow.flowOf @@ -31,7 +31,7 @@ import kotlinx.coroutines.flow.flowOf
val A_OIDC_DATA = OidcDetails(url = "a-url")
class FakeAuthenticationService(
class FakeMatrixAuthenticationService(
private val matrixClientResult: ((SessionId) -> Result<MatrixClient>)? = null
) : MatrixAuthenticationService {
private val homeserver = MutableStateFlow<MatrixHomeServerDetails?>(null)

8
libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt

@ -28,7 +28,7 @@ import io.element.android.libraries.matrix.test.AN_EVENT_ID @@ -28,7 +28,7 @@ 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_SECRET
import io.element.android.libraries.matrix.test.A_USER_ID
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.libraries.matrix.test.core.aBuildMeta
import io.element.android.libraries.push.impl.notifications.FakeNotifiableEventResolver
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
@ -135,7 +135,7 @@ class DefaultPushHandlerTest { @@ -135,7 +135,7 @@ class DefaultPushHandlerTest {
pushClientSecret = FakePushClientSecret(
getUserIdFromSecretResult = { null }
),
matrixAuthenticationService = FakeAuthenticationService().apply {
matrixAuthenticationService = FakeMatrixAuthenticationService().apply {
getLatestSessionIdLambda = { A_USER_ID }
},
incrementPushCounterResult = incrementPushCounterResult
@ -171,7 +171,7 @@ class DefaultPushHandlerTest { @@ -171,7 +171,7 @@ class DefaultPushHandlerTest {
pushClientSecret = FakePushClientSecret(
getUserIdFromSecretResult = { null }
),
matrixAuthenticationService = FakeAuthenticationService().apply {
matrixAuthenticationService = FakeMatrixAuthenticationService().apply {
getLatestSessionIdLambda = { null }
},
incrementPushCounterResult = incrementPushCounterResult
@ -247,7 +247,7 @@ class DefaultPushHandlerTest { @@ -247,7 +247,7 @@ class DefaultPushHandlerTest {
userPushStore: UserPushStore = FakeUserPushStore(),
pushClientSecret: PushClientSecret = FakePushClientSecret(),
buildMeta: BuildMeta = aBuildMeta(),
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService(),
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
diagnosticPushHandler: DiagnosticPushHandler = DiagnosticPushHandler(),
): DefaultPushHandler {
return DefaultPushHandler(

10
libraries/pushproviders/firebase/src/test/kotlin/io/element/android/libraries/pushproviders/firebase/DefaultFirebaseNewTokenHandlerTest.kt

@ -25,7 +25,7 @@ import io.element.android.libraries.matrix.test.A_USER_ID @@ -25,7 +25,7 @@ import io.element.android.libraries.matrix.test.A_USER_ID
import io.element.android.libraries.matrix.test.A_USER_ID_2
import io.element.android.libraries.matrix.test.A_USER_ID_3
import io.element.android.libraries.matrix.test.FakeMatrixClient
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.libraries.push.test.FakePusherSubscriber
import io.element.android.libraries.pushproviders.api.PusherSubscriber
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
@ -66,7 +66,7 @@ class DefaultFirebaseNewTokenHandlerTest { @@ -66,7 +66,7 @@ class DefaultFirebaseNewTokenHandlerTest {
storeData(aSessionData(A_USER_ID_2))
storeData(aSessionData(A_USER_ID_3))
},
matrixAuthenticationService = FakeAuthenticationService(
matrixAuthenticationService = FakeMatrixAuthenticationService(
matrixClientResult = { sessionId ->
when (sessionId) {
A_USER_ID -> Result.success(aMatrixClient1)
@ -105,7 +105,7 @@ class DefaultFirebaseNewTokenHandlerTest { @@ -105,7 +105,7 @@ class DefaultFirebaseNewTokenHandlerTest {
sessionStore = InMemoryMultiSessionsStore().apply {
storeData(aSessionData(A_USER_ID))
},
matrixAuthenticationService = FakeAuthenticationService(
matrixAuthenticationService = FakeMatrixAuthenticationService(
matrixClientResult = { _ ->
Result.failure(IllegalStateException())
}
@ -131,7 +131,7 @@ class DefaultFirebaseNewTokenHandlerTest { @@ -131,7 +131,7 @@ class DefaultFirebaseNewTokenHandlerTest {
sessionStore = InMemoryMultiSessionsStore().apply {
storeData(aSessionData(A_USER_ID))
},
matrixAuthenticationService = FakeAuthenticationService(
matrixAuthenticationService = FakeMatrixAuthenticationService(
matrixClientResult = { _ ->
Result.success(aMatrixClient1)
}
@ -154,7 +154,7 @@ class DefaultFirebaseNewTokenHandlerTest { @@ -154,7 +154,7 @@ class DefaultFirebaseNewTokenHandlerTest {
pusherSubscriber: PusherSubscriber = FakePusherSubscriber(),
sessionStore: SessionStore = InMemorySessionStore(),
userPushStoreFactory: UserPushStoreFactory = FakeUserPushStoreFactory(),
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService(),
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService(),
firebaseStore: FirebaseStore = InMemoryFirebaseStore(),
): FirebaseNewTokenHandler {
return DefaultFirebaseNewTokenHandler(

8
libraries/pushproviders/unifiedpush/src/test/kotlin/io/element/android/libraries/pushproviders/unifiedpush/DefaultUnifiedPushNewGatewayHandlerTest.kt

@ -22,7 +22,7 @@ import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService @@ -22,7 +22,7 @@ import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
import io.element.android.libraries.matrix.test.A_SECRET
import io.element.android.libraries.matrix.test.A_USER_ID
import io.element.android.libraries.matrix.test.FakeMatrixClient
import io.element.android.libraries.matrix.test.auth.FakeAuthenticationService
import io.element.android.libraries.matrix.test.auth.FakeMatrixAuthenticationService
import io.element.android.libraries.push.test.FakePusherSubscriber
import io.element.android.libraries.pushproviders.api.PusherSubscriber
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
@ -86,7 +86,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest { @@ -86,7 +86,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest {
pusherSubscriber = FakePusherSubscriber(
registerPusherResult = { _, _, _ -> Result.failure(IllegalStateException("an error")) }
),
matrixAuthenticationService = FakeAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
matrixAuthenticationService = FakeMatrixAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
)
val result = defaultUnifiedPushNewGatewayHandler.handle(
endpoint = "aEndpoint",
@ -114,7 +114,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest { @@ -114,7 +114,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest {
pusherSubscriber = FakePusherSubscriber(
registerPusherResult = lambda
),
matrixAuthenticationService = FakeAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
matrixAuthenticationService = FakeMatrixAuthenticationService(matrixClientResult = { Result.success(aMatrixClient) }),
)
val result = defaultUnifiedPushNewGatewayHandler.handle(
endpoint = "aEndpoint",
@ -131,7 +131,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest { @@ -131,7 +131,7 @@ class DefaultUnifiedPushNewGatewayHandlerTest {
pusherSubscriber: PusherSubscriber = FakePusherSubscriber(),
userPushStoreFactory: UserPushStoreFactory = FakeUserPushStoreFactory(),
pushClientSecret: PushClientSecret = FakePushClientSecret(),
matrixAuthenticationService: MatrixAuthenticationService = FakeAuthenticationService()
matrixAuthenticationService: MatrixAuthenticationService = FakeMatrixAuthenticationService()
): DefaultUnifiedPushNewGatewayHandler {
return DefaultUnifiedPushNewGatewayHandler(
pusherSubscriber = pusherSubscriber,

Loading…
Cancel
Save