From c50314ffbe8ad671faa575966bfb7841cc0bbe73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montw=C3=A9?= Date: Wed, 10 Jan 2024 13:32:18 +0100 Subject: [PATCH] Rename `AuthorizationState` property to value --- .../k9mail/feature/preview/account/InMemoryAccountStore.kt | 4 ++-- .../com/fsck/k9/account/AccountServerSettingsUpdater.kt | 2 +- .../com/fsck/k9/account/AccountServerSettingsUpdaterTest.kt | 6 +++--- .../account/common/data/InMemoryAccountStateRepository.kt | 2 +- .../account/common/domain/entity/AuthorizationState.kt | 2 +- .../account/common/domain/entity/AuthorizationStateTest.kt | 2 +- .../k9mail/feature/account/oauth/data/AuthStateExtension.kt | 4 ++-- .../feature/account/oauth/ui/AccountOAuthViewModelTest.kt | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/InMemoryAccountStore.kt b/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/InMemoryAccountStore.kt index 462b75e19..e0d4f0a72 100644 --- a/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/InMemoryAccountStore.kt +++ b/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/InMemoryAccountStore.kt @@ -39,12 +39,12 @@ class InMemoryAccountStore( accountMap[account.uuid] = if (isIncoming) { account.copy( incomingServerSettings = serverSettings, - authorizationState = authorizationState?.state, + authorizationState = authorizationState?.value, ) } else { account.copy( outgoingServerSettings = serverSettings, - authorizationState = authorizationState?.state, + authorizationState = authorizationState?.value, ) } diff --git a/app/k9mail/src/main/java/com/fsck/k9/account/AccountServerSettingsUpdater.kt b/app/k9mail/src/main/java/com/fsck/k9/account/AccountServerSettingsUpdater.kt index 71e0163d9..a2ec88452 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/account/AccountServerSettingsUpdater.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/account/AccountServerSettingsUpdater.kt @@ -67,7 +67,7 @@ class AccountServerSettingsUpdater( account.outgoingServerSettings = serverSettings } - account.oAuthState = authorizationState?.state + account.oAuthState = authorizationState?.value accountManager.saveAccount(account) diff --git a/app/k9mail/src/test/java/com/fsck/k9/account/AccountServerSettingsUpdaterTest.kt b/app/k9mail/src/test/java/com/fsck/k9/account/AccountServerSettingsUpdaterTest.kt index 861a64b21..6255ea3ab 100644 --- a/app/k9mail/src/test/java/com/fsck/k9/account/AccountServerSettingsUpdaterTest.kt +++ b/app/k9mail/src/test/java/com/fsck/k9/account/AccountServerSettingsUpdaterTest.kt @@ -53,7 +53,7 @@ class AccountServerSettingsUpdaterTest { assertThat(k9Account).isNotNull().all { prop(K9Account::incomingServerSettings).isEqualTo(updatedIncomingServerSettings) prop(K9Account::outgoingServerSettings).isEqualTo(OUTGOING_SERVER_SETTINGS) - prop(K9Account::oAuthState).isEqualTo(updatedAuthorizationState.state) + prop(K9Account::oAuthState).isEqualTo(updatedAuthorizationState.value) } } @@ -77,7 +77,7 @@ class AccountServerSettingsUpdaterTest { assertThat(k9Account).isNotNull().all { prop(K9Account::incomingServerSettings).isEqualTo(INCOMING_SERVER_SETTINGS) prop(K9Account::outgoingServerSettings).isEqualTo(updatedOutgoingServerSettings) - prop(K9Account::oAuthState).isEqualTo(updatedAuthorizationState.state) + prop(K9Account::oAuthState).isEqualTo(updatedAuthorizationState.value) } } @@ -136,7 +136,7 @@ class AccountServerSettingsUpdaterTest { ).apply { incomingServerSettings = INCOMING_SERVER_SETTINGS outgoingServerSettings = OUTGOING_SERVER_SETTINGS - oAuthState = AUTHORIZATION_STATE.state + oAuthState = AUTHORIZATION_STATE.value } } } diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt index aa4c4bb1d..35e62920b 100644 --- a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/data/InMemoryAccountStateRepository.kt @@ -60,7 +60,7 @@ class InMemoryAccountStateRepository( } override fun getAuthorizationState(): String? { - return state.authorizationState?.state + return state.authorizationState?.value } override fun updateAuthorizationState(authorizationState: String?) { diff --git a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationState.kt b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationState.kt index 5d4e46fef..74e410136 100644 --- a/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationState.kt +++ b/feature/account/common/src/main/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationState.kt @@ -1,5 +1,5 @@ package app.k9mail.feature.account.common.domain.entity data class AuthorizationState( - val state: String? = null, + val value: String? = null, ) diff --git a/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationStateTest.kt b/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationStateTest.kt index 1311b6607..0ccdc696b 100644 --- a/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationStateTest.kt +++ b/feature/account/common/src/test/kotlin/app/k9mail/feature/account/common/domain/entity/AuthorizationStateTest.kt @@ -10,6 +10,6 @@ class AuthorizationStateTest { fun `should default to null state`() { val authorizationState = AuthorizationState() - assertThat(authorizationState.state).isNull() + assertThat(authorizationState.value).isNull() } } diff --git a/feature/account/oauth/src/main/kotlin/app/k9mail/feature/account/oauth/data/AuthStateExtension.kt b/feature/account/oauth/src/main/kotlin/app/k9mail/feature/account/oauth/data/AuthStateExtension.kt index daba4ec57..b02846f11 100644 --- a/feature/account/oauth/src/main/kotlin/app/k9mail/feature/account/oauth/data/AuthStateExtension.kt +++ b/feature/account/oauth/src/main/kotlin/app/k9mail/feature/account/oauth/data/AuthStateExtension.kt @@ -7,7 +7,7 @@ import timber.log.Timber fun AuthState.toAuthorizationState(): AuthorizationState { return try { - AuthorizationState(state = jsonSerializeString()) + AuthorizationState(value = jsonSerializeString()) } catch (e: JSONException) { Timber.e(e, "Error serializing AuthorizationState") AuthorizationState() @@ -16,7 +16,7 @@ fun AuthState.toAuthorizationState(): AuthorizationState { fun AuthorizationState.toAuthState(): AuthState { return try { - state?.let { AuthState.jsonDeserialize(it) } ?: AuthState() + value?.let { AuthState.jsonDeserialize(it) } ?: AuthState() } catch (e: JSONException) { Timber.e(e, "Error deserializing AuthorizationState") AuthState() diff --git a/feature/account/oauth/src/test/kotlin/app/k9mail/feature/account/oauth/ui/AccountOAuthViewModelTest.kt b/feature/account/oauth/src/test/kotlin/app/k9mail/feature/account/oauth/ui/AccountOAuthViewModelTest.kt index a7769480b..daf97c5a6 100644 --- a/feature/account/oauth/src/test/kotlin/app/k9mail/feature/account/oauth/ui/AccountOAuthViewModelTest.kt +++ b/feature/account/oauth/src/test/kotlin/app/k9mail/feature/account/oauth/ui/AccountOAuthViewModelTest.kt @@ -169,7 +169,7 @@ class AccountOAuthViewModelTest { @Test fun `should finish OAuth sign in when onOAuthResult received with success`() = runTest { val initialState = defaultState - val authorizationState = AuthorizationState(state = "state") + val authorizationState = AuthorizationState(value = "state") val testSubject = createTestSubject( authorizationResult = AuthorizationResult.Success(authorizationState), initialState = initialState,