Rename AuthorizationState
property to value
This commit is contained in:
parent
63d834d18c
commit
c50314ffbe
8 changed files with 12 additions and 12 deletions
|
@ -39,12 +39,12 @@ class InMemoryAccountStore(
|
||||||
accountMap[account.uuid] = if (isIncoming) {
|
accountMap[account.uuid] = if (isIncoming) {
|
||||||
account.copy(
|
account.copy(
|
||||||
incomingServerSettings = serverSettings,
|
incomingServerSettings = serverSettings,
|
||||||
authorizationState = authorizationState?.state,
|
authorizationState = authorizationState?.value,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
account.copy(
|
account.copy(
|
||||||
outgoingServerSettings = serverSettings,
|
outgoingServerSettings = serverSettings,
|
||||||
authorizationState = authorizationState?.state,
|
authorizationState = authorizationState?.value,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class AccountServerSettingsUpdater(
|
||||||
account.outgoingServerSettings = serverSettings
|
account.outgoingServerSettings = serverSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
account.oAuthState = authorizationState?.state
|
account.oAuthState = authorizationState?.value
|
||||||
|
|
||||||
accountManager.saveAccount(account)
|
accountManager.saveAccount(account)
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class AccountServerSettingsUpdaterTest {
|
||||||
assertThat(k9Account).isNotNull().all {
|
assertThat(k9Account).isNotNull().all {
|
||||||
prop(K9Account::incomingServerSettings).isEqualTo(updatedIncomingServerSettings)
|
prop(K9Account::incomingServerSettings).isEqualTo(updatedIncomingServerSettings)
|
||||||
prop(K9Account::outgoingServerSettings).isEqualTo(OUTGOING_SERVER_SETTINGS)
|
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 {
|
assertThat(k9Account).isNotNull().all {
|
||||||
prop(K9Account::incomingServerSettings).isEqualTo(INCOMING_SERVER_SETTINGS)
|
prop(K9Account::incomingServerSettings).isEqualTo(INCOMING_SERVER_SETTINGS)
|
||||||
prop(K9Account::outgoingServerSettings).isEqualTo(updatedOutgoingServerSettings)
|
prop(K9Account::outgoingServerSettings).isEqualTo(updatedOutgoingServerSettings)
|
||||||
prop(K9Account::oAuthState).isEqualTo(updatedAuthorizationState.state)
|
prop(K9Account::oAuthState).isEqualTo(updatedAuthorizationState.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class AccountServerSettingsUpdaterTest {
|
||||||
).apply {
|
).apply {
|
||||||
incomingServerSettings = INCOMING_SERVER_SETTINGS
|
incomingServerSettings = INCOMING_SERVER_SETTINGS
|
||||||
outgoingServerSettings = OUTGOING_SERVER_SETTINGS
|
outgoingServerSettings = OUTGOING_SERVER_SETTINGS
|
||||||
oAuthState = AUTHORIZATION_STATE.state
|
oAuthState = AUTHORIZATION_STATE.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class InMemoryAccountStateRepository(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAuthorizationState(): String? {
|
override fun getAuthorizationState(): String? {
|
||||||
return state.authorizationState?.state
|
return state.authorizationState?.value
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateAuthorizationState(authorizationState: String?) {
|
override fun updateAuthorizationState(authorizationState: String?) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package app.k9mail.feature.account.common.domain.entity
|
package app.k9mail.feature.account.common.domain.entity
|
||||||
|
|
||||||
data class AuthorizationState(
|
data class AuthorizationState(
|
||||||
val state: String? = null,
|
val value: String? = null,
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,6 +10,6 @@ class AuthorizationStateTest {
|
||||||
fun `should default to null state`() {
|
fun `should default to null state`() {
|
||||||
val authorizationState = AuthorizationState()
|
val authorizationState = AuthorizationState()
|
||||||
|
|
||||||
assertThat(authorizationState.state).isNull()
|
assertThat(authorizationState.value).isNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import timber.log.Timber
|
||||||
|
|
||||||
fun AuthState.toAuthorizationState(): AuthorizationState {
|
fun AuthState.toAuthorizationState(): AuthorizationState {
|
||||||
return try {
|
return try {
|
||||||
AuthorizationState(state = jsonSerializeString())
|
AuthorizationState(value = jsonSerializeString())
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
Timber.e(e, "Error serializing AuthorizationState")
|
Timber.e(e, "Error serializing AuthorizationState")
|
||||||
AuthorizationState()
|
AuthorizationState()
|
||||||
|
@ -16,7 +16,7 @@ fun AuthState.toAuthorizationState(): AuthorizationState {
|
||||||
|
|
||||||
fun AuthorizationState.toAuthState(): AuthState {
|
fun AuthorizationState.toAuthState(): AuthState {
|
||||||
return try {
|
return try {
|
||||||
state?.let { AuthState.jsonDeserialize(it) } ?: AuthState()
|
value?.let { AuthState.jsonDeserialize(it) } ?: AuthState()
|
||||||
} catch (e: JSONException) {
|
} catch (e: JSONException) {
|
||||||
Timber.e(e, "Error deserializing AuthorizationState")
|
Timber.e(e, "Error deserializing AuthorizationState")
|
||||||
AuthState()
|
AuthState()
|
||||||
|
|
|
@ -169,7 +169,7 @@ class AccountOAuthViewModelTest {
|
||||||
@Test
|
@Test
|
||||||
fun `should finish OAuth sign in when onOAuthResult received with success`() = runTest {
|
fun `should finish OAuth sign in when onOAuthResult received with success`() = runTest {
|
||||||
val initialState = defaultState
|
val initialState = defaultState
|
||||||
val authorizationState = AuthorizationState(state = "state")
|
val authorizationState = AuthorizationState(value = "state")
|
||||||
val testSubject = createTestSubject(
|
val testSubject = createTestSubject(
|
||||||
authorizationResult = AuthorizationResult.Success(authorizationState),
|
authorizationResult = AuthorizationResult.Success(authorizationState),
|
||||||
initialState = initialState,
|
initialState = initialState,
|
||||||
|
|
Loading…
Reference in a new issue