From d3d99dd3bad9e5a7b07dabe320f1d2855f732540 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Thu, 3 Mar 2022 13:21:04 +0100 Subject: [PATCH] Replaces mocks with fixtures in fake json adapters --- .../db/sessionparams/FakeCredentialsJsonAdapter.kt | 11 +++++++---- .../FakeHomeServerConnectionConfigJsonAdapter.kt | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeCredentialsJsonAdapter.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeCredentialsJsonAdapter.kt index bcec6d7efe..7c0d78f96d 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeCredentialsJsonAdapter.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeCredentialsJsonAdapter.kt @@ -20,18 +20,21 @@ import com.squareup.moshi.JsonAdapter import io.mockk.every import io.mockk.mockk import org.matrix.android.sdk.api.auth.data.Credentials +import org.matrix.android.sdk.test.fakes.auth.db.sessionparams.FakeSessionParamsMapperMoshi.Companion.sessionParams +import org.matrix.android.sdk.test.fakes.auth.db.sessionparams.FakeSessionParamsMapperMoshi.Companion.sessionParamsEntity +import org.matrix.android.sdk.test.fixtures.CredentialsFixture.aCredentials internal class FakeCredentialsJsonAdapter { val instance: JsonAdapter = mockk() init { - every { instance.fromJson(FakeSessionParamsMapperMoshi.sessionParamsEntity.credentialsJson) } returns credentials - every { instance.toJson(FakeSessionParamsMapperMoshi.sessionParams.credentials) } returns CREDENTIALS_JSON + every { instance.fromJson(sessionParamsEntity.credentialsJson) } returns credentials + every { instance.toJson(sessionParams.credentials) } returns CREDENTIALS_JSON } fun givenNullDeserialization() { - every { instance.fromJson(FakeSessionParamsMapperMoshi.sessionParamsEntity.credentialsJson) } returns null + every { instance.fromJson(sessionParamsEntity.credentialsJson) } returns null } fun givenNullSerialization() { @@ -39,7 +42,7 @@ internal class FakeCredentialsJsonAdapter { } companion object { - val credentials: Credentials = mockk() + val credentials = aCredentials() const val CREDENTIALS_JSON = "credentials_json" } } diff --git a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt index 4d0e6615c4..6a9285e650 100644 --- a/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt +++ b/matrix-sdk-android/src/test/java/org/matrix/android/sdk/test/fakes/auth/db/sessionparams/FakeHomeServerConnectionConfigJsonAdapter.kt @@ -41,7 +41,7 @@ internal class FakeHomeServerConnectionConfigJsonAdapter { } companion object { - val homeServerConnectionConfig: HomeServerConnectionConfig = mockk() + val homeServerConnectionConfig = HomeServerConnectionConfig.Builder().build() const val HOME_SERVER_CONNECTION_CONFIG_JSON = "home_server_connection_config_json" } }