Rename AuthorizationState property to value

This commit is contained in:
Wolf-Martell Montwé 2024-01-10 13:32:18 +01:00
parent 63d834d18c
commit c50314ffbe
No known key found for this signature in database
GPG key ID: 6D45B21512ACBF72
8 changed files with 12 additions and 12 deletions

View file

@ -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,
)
}

View file

@ -67,7 +67,7 @@ class AccountServerSettingsUpdater(
account.outgoingServerSettings = serverSettings
}
account.oAuthState = authorizationState?.state
account.oAuthState = authorizationState?.value
accountManager.saveAccount(account)

View file

@ -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
}
}
}

View file

@ -60,7 +60,7 @@ class InMemoryAccountStateRepository(
}
override fun getAuthorizationState(): String? {
return state.authorizationState?.state
return state.authorizationState?.value
}
override fun updateAuthorizationState(authorizationState: String?) {

View file

@ -1,5 +1,5 @@
package app.k9mail.feature.account.common.domain.entity
data class AuthorizationState(
val state: String? = null,
val value: String? = null,
)

View file

@ -10,6 +10,6 @@ class AuthorizationStateTest {
fun `should default to null state`() {
val authorizationState = AuthorizationState()
assertThat(authorizationState.state).isNull()
assertThat(authorizationState.value).isNull()
}
}

View file

@ -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()

View file

@ -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,