Kotlin 1.9.0 (#3835)
Update to Kotlin 1.9.0 and migrate to newer language idioms. - Remove unnecessary @OptIn for features migrated to mainstream - Use `data object` where appropriate - Use new enum `entries` property
This commit is contained in:
parent
5391b5f797
commit
40bd95d752
29 changed files with 44 additions and 71 deletions
|
|
@ -22,7 +22,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
|||
import com.google.gson.Gson
|
||||
import com.keylesspalace.tusky.entity.Notification
|
||||
import com.keylesspalace.tusky.network.MastodonApi
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
import org.junit.Assert.assertEquals
|
||||
|
|
@ -38,7 +37,6 @@ import retrofit2.Response
|
|||
|
||||
@Config(sdk = [28])
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsPagingSourceTest {
|
||||
@Test
|
||||
fun `load() returns error message on HTTP error`() = runTest {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import retrofit2.HttpException
|
|||
import retrofit2.Response
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class MainCoroutineRule constructor(private val dispatcher: TestDispatcher = UnconfinedTestDispatcher()) : TestWatcher() {
|
||||
class MainCoroutineRule(private val dispatcher: TestDispatcher = UnconfinedTestDispatcher()) : TestWatcher() {
|
||||
override fun starting(description: Description) {
|
||||
super.starting(description)
|
||||
Dispatchers.setMain(dispatcher)
|
||||
|
|
@ -62,7 +62,6 @@ class MainCoroutineRule constructor(private val dispatcher: TestDispatcher = Unc
|
|||
|
||||
@Config(sdk = [28])
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
abstract class NotificationsViewModelTestBase {
|
||||
protected lateinit var notificationsRepository: NotificationsRepository
|
||||
protected lateinit var sharedPreferencesMap: MutableMap<String, Boolean>
|
||||
|
|
@ -73,7 +72,7 @@ abstract class NotificationsViewModelTestBase {
|
|||
protected lateinit var viewModel: NotificationsViewModel
|
||||
|
||||
/** Empty success response, for API calls that return one */
|
||||
protected var emptySuccess = Response.success("".toResponseBody())
|
||||
protected var emptySuccess: Response<ResponseBody> = Response.success("".toResponseBody())
|
||||
|
||||
/** Empty error response, for API calls that return one */
|
||||
protected var emptyError: Response<ResponseBody> = Response.error(404, "".toResponseBody())
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ package com.keylesspalace.tusky.components.notifications
|
|||
|
||||
import app.cash.turbine.test
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.doReturn
|
||||
|
|
@ -34,7 +33,6 @@ import org.mockito.kotlin.verify
|
|||
* This is only tested in the success case; if it passed there it must also
|
||||
* have passed in the error case.
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestClearNotifications : NotificationsViewModelTestBase() {
|
||||
@Test
|
||||
fun `clearing notifications succeeds && invalidate the repository`() = runTest {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import app.cash.turbine.test
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import com.keylesspalace.tusky.db.AccountEntity
|
||||
import com.keylesspalace.tusky.entity.Notification
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.argumentCaptor
|
||||
|
|
@ -33,7 +32,6 @@ import org.mockito.kotlin.verify
|
|||
* - Is the [UiState] updated correctly?
|
||||
* - Are the correct [AccountManager] functions called, with the correct arguments?
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestFilter : NotificationsViewModelTestBase() {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import app.cash.turbine.test
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import com.keylesspalace.tusky.entity.Relationship
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.any
|
||||
|
|
@ -39,7 +38,6 @@ import org.mockito.kotlin.verify
|
|||
* This is only tested in the success case; if it passed there it must also
|
||||
* have passed in the error case.
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestNotificationAction : NotificationsViewModelTestBase() {
|
||||
/** Dummy relationship */
|
||||
private val relationship = Relationship(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import at.connyduck.calladapter.networkresult.NetworkResult
|
|||
import com.google.common.truth.Truth.assertThat
|
||||
import com.keylesspalace.tusky.FilterV1Test.Companion.mockStatus
|
||||
import com.keylesspalace.tusky.viewdata.StatusViewData
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.any
|
||||
|
|
@ -40,7 +39,6 @@ import org.mockito.kotlin.verify
|
|||
* This is only tested in the success case; if it passed there it must also
|
||||
* have passed in the error case.
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestStatusAction : NotificationsViewModelTestBase() {
|
||||
private val status = mockStatus(pollOptions = listOf("Choice 1", "Choice 2", "Choice 3"))
|
||||
private val statusViewData = StatusViewData.Concrete(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import com.keylesspalace.tusky.appstore.PreferenceChangedEvent
|
|||
import com.keylesspalace.tusky.settings.PrefKeys
|
||||
import com.keylesspalace.tusky.util.CardViewMode
|
||||
import com.keylesspalace.tusky.util.StatusDisplayOptions
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
|
|
@ -34,7 +33,6 @@ import org.junit.Test
|
|||
* - Does the make() function correctly use an updated preference?
|
||||
* - Is the correct update emitted when a relevant preference changes?
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestStatusDisplayOptions : NotificationsViewModelTestBase() {
|
||||
|
||||
private val defaultStatusDisplayOptions = StatusDisplayOptions(
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import com.google.common.truth.Truth.assertThat
|
|||
import com.keylesspalace.tusky.appstore.PreferenceChangedEvent
|
||||
import com.keylesspalace.tusky.entity.Notification
|
||||
import com.keylesspalace.tusky.settings.PrefKeys
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
|
||||
|
|
@ -32,7 +31,6 @@ import org.junit.Test
|
|||
* - Is the initial value taken from values in sharedPreferences and account?
|
||||
* - Is the correct update emitted when a relevant preference changes?
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestUiState : NotificationsViewModelTestBase() {
|
||||
|
||||
private val initialUiState = UiState(
|
||||
|
|
|
|||
|
|
@ -19,13 +19,11 @@ package com.keylesspalace.tusky.components.notifications
|
|||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import com.keylesspalace.tusky.db.AccountEntity
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.argumentCaptor
|
||||
import org.mockito.kotlin.verify
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class NotificationsViewModelTestVisibleId : NotificationsViewModelTestBase() {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue