diff --git a/CHANGELOG.md b/CHANGELOG.md index 8307b59b0..ff969b0a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Change Log +## 2.4.0 +- Add covariant recreation support (#565) +- Exposing unique subscription handling for custom flow operations (#560) +- Add support for restoring ViewModels that were initially created with a companion factory in a superclass #566 ## 2.3.0 - Error handling enhancements (#540) diff --git a/build.gradle b/build.gradle index 006f9b2fb..5c215e4bf 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ buildscript { } plugins { - id("io.gitlab.arturbosch.detekt").version("1.16.0-RC2") + id("io.gitlab.arturbosch.detekt").version("1.18.1") } apply plugin: 'io.gitlab.arturbosch.detekt' diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7013004e0..eccfdf1ed 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -14,5 +14,5 @@ dependencies { implementation(gradleApi()) implementation("com.android.tools.build:gradle:7.0.0") implementation("org.jacoco:org.jacoco.core:0.8.5") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30") } diff --git a/buildSrc/src/main/java/dependencies.kt b/buildSrc/src/main/java/dependencies.kt index a41421006..cfc831463 100644 --- a/buildSrc/src/main/java/dependencies.kt +++ b/buildSrc/src/main/java/dependencies.kt @@ -1,9 +1,9 @@ object Versions { // Build tools and SDK const val buildTools = "30.0.3" - const val compileSdk = 30 - const val gradlePlugin = "7.0.0" - const val kotlin = "1.5.21" + const val compileSdk = 31 + const val gradlePlugin = "7.0.2" + const val kotlin = "1.5.30" const val minSdk = 16 const val targetSdk = 29 @@ -15,15 +15,15 @@ object Versions { const val cardview = "1.0.0" const val constraintlayout = "2.0.0" const val coordinatorLayout = "1.1.0" - const val compose = "1.0.2" + const val compose = "1.0.3" const val core = "1.5.0" const val fragment = "1.3.4" const val lifecycle = "2.3.1" const val navigation = "2.3.5" - const val navigationCompose = "2.4.0-alpha01" + const val navigationCompose = "2.4.0-alpha10" const val recyclerview = "1.2.0" const val room = "2.3.0" - const val viewModelCompose = "1.0.0-alpha05" + const val viewModelCompose = "2.4.0-rc01" // Libraries const val autoValue = "1.6.6" @@ -31,7 +31,7 @@ object Versions { const val epoxy = "4.0.0" const val hilt = "2.36" const val koin = "2.0.1" - const val kotlinCoroutines = "1.5.1" + const val kotlinCoroutines = "1.5.2" const val lottie = "3.4.0" const val moshi = "1.9.2" const val multidex = "2.0.1" diff --git a/counter/src/test/java/com/airbnb/mvrx/counter/CounterViewModelTest.kt b/counter/src/test/java/com/airbnb/mvrx/counter/CounterViewModelTest.kt index 1f22d1503..b5e356853 100644 --- a/counter/src/test/java/com/airbnb/mvrx/counter/CounterViewModelTest.kt +++ b/counter/src/test/java/com/airbnb/mvrx/counter/CounterViewModelTest.kt @@ -22,4 +22,4 @@ class CounterViewModelTest { @ClassRule val mvrxTestRule = MvRxTestRule() } -} \ No newline at end of file +} diff --git a/detekt.gradle b/detekt.gradle index 042943d15..47fa16dfa 100644 --- a/detekt.gradle +++ b/detekt.gradle @@ -3,7 +3,7 @@ apply plugin: 'io.gitlab.arturbosch.detekt' tasks.detekt.jvmTarget = "1.8" dependencies { - detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.16.0-RC2" + detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.18.1" } detekt { diff --git a/detekt.yml b/detekt.yml index 300d44d3b..a37dfff44 100644 --- a/detekt.yml +++ b/detekt.yml @@ -70,7 +70,7 @@ formatting: active: true comments: - excludes: ['.*/test/.*', '.*Test.kt', '.*Spec.kt'] + excludes: ['**/test/**', '.*Test.kt'] active: true CommentOverPrivateFunction: active: false @@ -154,7 +154,7 @@ empty-blocks: EmptyForBlock: active: true EmptyFunctionBlock: - active: true + active: false ignoreOverridden: false EmptyIfBlock: active: true @@ -261,6 +261,7 @@ naming: excludeClassPattern: '$^' performance: + excludes: ['**/test/**', '.*Test.kt'] active: true ForEachOnRange: active: false @@ -303,6 +304,7 @@ potential-bugs: active: true style: + excludes: ['**/test/**', '.*Test.kt'] active: true CollapsibleIfStatements: active: true @@ -339,6 +341,7 @@ style: MandatoryBracesIfStatements: active: false # TODO: consider this MaxLineLength: + excludes: ['**/test/**', '.*Test.kt'] active: true maxLineLength: 175 excludePackageStatements: false diff --git a/dogs/src/test/java/com/airbnb/mvrx/dogs/DogStateTest.kt b/dogs/src/test/java/com/airbnb/mvrx/dogs/DogStateTest.kt index b16c58453..63ce728d2 100644 --- a/dogs/src/test/java/com/airbnb/mvrx/dogs/DogStateTest.kt +++ b/dogs/src/test/java/com/airbnb/mvrx/dogs/DogStateTest.kt @@ -12,4 +12,4 @@ class DogStateTest { val state = DogState(dogs = Success(listOf(dog)), lovedDogId = dog.id) assertEquals(dog, state.lovedDog) } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 5eef6b4d9..8a0479538 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=2.4.0-SNAPSHOT +VERSION_NAME=2.4.0 GROUP=com.airbnb.android POM_DESCRIPTION=Mavericks is an Android application framework that makes product development fast and fun. POM_URL=https://github.com/airbnb/mavericks diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 29e413457..a0f7639f7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/hellodagger/src/test/java/com/airbnb/mvrx/hellodagger/HelloDaggerViewModelTest.kt b/hellodagger/src/test/java/com/airbnb/mvrx/hellodagger/HelloDaggerViewModelTest.kt index 2ec0adf40..4e89bb8d0 100644 --- a/hellodagger/src/test/java/com/airbnb/mvrx/hellodagger/HelloDaggerViewModelTest.kt +++ b/hellodagger/src/test/java/com/airbnb/mvrx/hellodagger/HelloDaggerViewModelTest.kt @@ -15,9 +15,8 @@ internal class HelloDaggerViewModelTest { @get:Rule val mvrxRule = MvRxTestRule() - @Test - fun `fetches message when created`() { + fun `fetches message when created`() { val repo = mockk { every { sayHello() } returns flowOf("Hello!") } @@ -26,4 +25,4 @@ internal class HelloDaggerViewModelTest { assertEquals(Success("Hello!"), state.message) } } -} \ No newline at end of file +} diff --git a/launcher/src/main/java/com/airbnb/mvrx/launcher/MavericksLauncherFragment.kt b/launcher/src/main/java/com/airbnb/mvrx/launcher/MavericksLauncherFragment.kt index b14b59fde..7cf11a5d2 100644 --- a/launcher/src/main/java/com/airbnb/mvrx/launcher/MavericksLauncherFragment.kt +++ b/launcher/src/main/java/com/airbnb/mvrx/launcher/MavericksLauncherFragment.kt @@ -176,7 +176,11 @@ class MavericksLauncherFragment : MavericksLauncherBaseFragment() { } } - private fun EpoxyController.addMocksForSelectedView(state: MavericksLauncherState, mocksToShow: List>?, context: Context) { + private fun EpoxyController.addMocksForSelectedView( + state: MavericksLauncherState, + mocksToShow: List>?, + context: Context + ) { if (mocksToShow == null || mocksToShow.isEmpty()) { textRow { id("no mocks") diff --git a/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/DataClassSetDsl.kt b/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/DataClassSetDsl.kt index d5659a09c..42458103f 100644 --- a/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/DataClassSetDsl.kt +++ b/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/DataClassSetDsl.kt @@ -59,14 +59,18 @@ interface DataClassSetDsl { /** * A shortcut to setting an Async property to Loading, instead of "data.set { ::property }.with { Loading() }". */ - fun , AsyncType> DataClass.setLoading(block: DataClass.() -> KProperty0): DataClass { + fun , AsyncType> DataClass.setLoading( + block: DataClass.() -> KProperty0 + ): DataClass { return Setter?>(this, block()).with { Loading() } } /** * A shortcut to setting an Async property to Fail, instead of "data.set { ::property }.with { Fail() }". */ - fun , AsyncType> DataClass.setNetworkFailure(block: DataClass.() -> KProperty0): DataClass { + fun , AsyncType> DataClass.setNetworkFailure( + block: DataClass.() -> KProperty0 + ): DataClass { return Setter?>(this, block()).with { Fail(Throwable("Network request failed")) } } @@ -125,7 +129,10 @@ interface DataClassSetDsl { /** * Helper to copy a nested class and update a property on it. */ - class Setter(private val instance: DataClass, internal val property: KProperty0) { + class Setter( + private val instance: DataClass, + internal val property: KProperty0 + ) { init { val clazz = instance::class if (instance is Async<*>) { diff --git a/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/MockableMavericksViewModelConfig.kt b/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/MockableMavericksViewModelConfig.kt index 9510b6d2a..0b827b671 100644 --- a/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/MockableMavericksViewModelConfig.kt +++ b/mvrx-mocking/src/main/kotlin/com/airbnb/mvrx/mocking/MockableMavericksViewModelConfig.kt @@ -53,11 +53,15 @@ class MockableMavericksViewModelConfig( updateStateStore() } - fun addOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) { + fun addOnExecuteListener( + listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit + ) { onExecuteListeners.add(listener) } - fun removeOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) { + fun removeOnExecuteListener( + listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit + ) { onExecuteListeners.remove(listener) } @@ -300,12 +304,16 @@ open class MockMavericksViewModelConfigFactory( /** * Add a lambda that will be invoked whenever [MavericksViewModel.execute] is used. */ - fun addOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) { + fun addOnExecuteListener( + listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit + ) { onExecuteListeners.add(listener) mockConfigs.values.forEach { it.addOnExecuteListener(listener) } } - fun removeOnExecuteListener(listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit) { + fun removeOnExecuteListener( + listener: (MavericksViewModelConfig<*>, MavericksViewModel<*>, MavericksViewModelConfig.BlockExecutions) -> Unit + ) { onExecuteListeners.remove(listener) mockConfigs.values.forEach { it.removeOnExecuteListener(listener) } } diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/AutoValueTypePrinterTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/AutoValueTypePrinterTest.kt index 9d61206c1..7aee5d024 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/AutoValueTypePrinterTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/AutoValueTypePrinterTest.kt @@ -26,7 +26,8 @@ class AutoValueTypePrinterTest : BaseTest() { "val mockAutoValue_AutoValueClass by lazy { AutoValueClass.builder()\n" + ".setName(\"foo\")\n" + ".setNumberOfLegs(1)\n" + - ".build() }", constructorCode.lazyPropertyToCreateObject + ".build() }", + constructorCode.lazyPropertyToCreateObject ) } diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/BaseTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/BaseTest.kt index ec2ad0705..0e1a989f2 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/BaseTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/BaseTest.kt @@ -89,7 +89,6 @@ abstract class BaseTest { } .commitNow() - return controller } } diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ConstructorCodeGeneratorTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ConstructorCodeGeneratorTest.kt index f4be37f5a..d04ea0e2b 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ConstructorCodeGeneratorTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ConstructorCodeGeneratorTest.kt @@ -217,14 +217,18 @@ class ConstructorCodeGeneratorTest : BaseTest() { ).expect("ConstructorCodeGeneratorTest.Test(list=arrayOf(1,2,3,4))") } - private fun com.airbnb.mvrx.mocking.printer.ConstructorCodeGenerator.expect(expectedCode: String) { + private fun com.airbnb.mvrx.mocking.printer.ConstructorCodeGenerator.expect( + expectedCode: String + ) { assertEquals("valmockTestbylazy{$expectedCode}", lazyPropertyToCreateObject.removeWhiteSpace()) } data class StateWithJsonObject(val json: String = """{"color":"red","numbers":[{"favorite":7},{"lowest":0}]}""") : MavericksState - data class StateWithInvalidJsonObject(val json: String = """not valid{"color":"red","numbers":[{"favorite":7},{"lowest":0}]}""") : + data class StateWithInvalidJsonObject( + val json: String = """not valid{"color":"red","numbers":[{"favorite":7},{"lowest":0}]}""" + ) : MavericksState data class StateWithJsonArray(val json: String = """[{"favorite":7},{"lowest":0}]""") : @@ -268,4 +272,4 @@ private fun String.removeWhiteSpace(): String { .replace("\n", "") .replace("\r", "") .replace("\t", "") -} \ No newline at end of file +} diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/CoroutineTestUtil.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/CoroutineTestUtil.kt index 8c934a2e6..1661bc0d2 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/CoroutineTestUtil.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/CoroutineTestUtil.kt @@ -6,4 +6,4 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.test.TestCoroutineDispatcher -fun testCoroutineScope() = CoroutineScope(SupervisorJob() + TestCoroutineDispatcher()) \ No newline at end of file +fun testCoroutineScope() = CoroutineScope(SupervisorJob() + TestCoroutineDispatcher()) diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/DataClassSetDslTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/DataClassSetDslTest.kt index 2abce4aa2..b861e2163 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/DataClassSetDslTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/DataClassSetDslTest.kt @@ -98,4 +98,4 @@ data class TestClass2( data class TestClass3( val str: String = "" -) \ No newline at end of file +) diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MavericksViewModelConfigTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MavericksViewModelConfigTest.kt index de838b561..cc1069876 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MavericksViewModelConfigTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MavericksViewModelConfigTest.kt @@ -146,4 +146,4 @@ class MavericksViewModelConfigTest : BaseTest() { class TestViewModel : MavericksViewModel(TestState()) data class TestState(val num: Int = 0) : MavericksState -} \ No newline at end of file +} diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockStateHolderTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockStateHolderTest.kt index 32222fa88..f8dcf35bc 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockStateHolderTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockStateHolderTest.kt @@ -82,7 +82,6 @@ class MockStateHolderTest : BaseTest() { defaultState = defaultState, defaultArgs = null ) { - } } else -> MavericksViewMocks.DefaultViewMocksProvider.mavericksViewMocks(view) @@ -220,7 +219,6 @@ class MockStateHolderTest : BaseTest() { defaultState = TestState(num = 4), defaultArgs = null ) { - } } else -> MavericksViewMocks.DefaultViewMocksProvider.mavericksViewMocks(view) @@ -253,7 +251,6 @@ class MockStateHolderTest : BaseTest() { defaultState = TestState(num = 3), defaultArgs = null ) { - } } @@ -266,4 +263,4 @@ class MockStateHolderTest : BaseTest() { data class TestState(val num: Int = 0) : MavericksState class FragmentVM(initialState: TestState) : MavericksViewModel(initialState) -} \ No newline at end of file +} diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockableMavericksStateStoreTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockableMavericksStateStoreTest.kt index 55c440745..2f0d0f323 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockableMavericksStateStoreTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/MockableMavericksStateStoreTest.kt @@ -195,4 +195,4 @@ class MockableMavericksStateStoreTest : BaseTest() { } private data class TestState(val num: Int = 0) : MavericksState -} \ No newline at end of file +} diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/TestActivity.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/TestActivity.kt index ef2720bea..5db11aa7f 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/TestActivity.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/TestActivity.kt @@ -21,4 +21,4 @@ open class TestActivity : AppCompatActivity() { } } -const val CONTAINER_ID = 111 \ No newline at end of file +const val CONTAINER_ID = 111 diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelBlockExecutionTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelBlockExecutionTest.kt index 809f48502..bc6c4af56 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelBlockExecutionTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelBlockExecutionTest.kt @@ -58,4 +58,4 @@ class ViewModelBlockExecutionTest : BaseTest() { } } -fun > VM.state(): S = config.stateStore.state \ No newline at end of file +fun > VM.state(): S = config.stateStore.state diff --git a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelDelegateProviderTest.kt b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelDelegateProviderTest.kt index d51c7f784..6761ece8b 100644 --- a/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelDelegateProviderTest.kt +++ b/mvrx-mocking/src/test/kotlin/com/airbnb/mvrx/mocking/ViewModelDelegateProviderTest.kt @@ -54,9 +54,11 @@ class ViewModelDelegateProviderTest : BaseTest() { @Test fun existingViewModelWithMockedState() { - val mockVariants = getMockVariants(viewProvider = { _, _ -> - Frag2() - }) + val mockVariants = getMockVariants( + viewProvider = { _, _ -> + Frag2() + } + ) checkNotNull(mockVariants) @@ -75,9 +77,11 @@ class ViewModelDelegateProviderTest : BaseTest() { @Test fun parentFragmentViewModelWithMockedState() { - val mockVariants = getMockVariants(viewProvider = { _, _ -> - Frag3() - }) + val mockVariants = getMockVariants( + viewProvider = { _, _ -> + Frag3() + } + ) checkNotNull(mockVariants) @@ -108,7 +112,6 @@ class ViewModelDelegateProviderTest : BaseTest() { defaultState2 = TestState(2), defaultArgs = null ) { - } } @@ -123,7 +126,6 @@ class ViewModelDelegateProviderTest : BaseTest() { defaultState = TestState(2), defaultArgs = null ) { - } } @@ -138,7 +140,6 @@ class ViewModelDelegateProviderTest : BaseTest() { defaultState = TestState(2), defaultArgs = null ) { - } } diff --git a/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/MvRxView.kt b/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/MvRxView.kt index 985071d05..ade48a9cd 100644 --- a/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/MvRxView.kt +++ b/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/MvRxView.kt @@ -25,7 +25,10 @@ interface MvRxView : MavericksView { * * Default: [RedeliverOnStart]. */ - fun BaseMvRxViewModel.subscribe(deliveryMode: DeliveryMode = RedeliverOnStart, subscriber: (S) -> Unit) = + fun BaseMvRxViewModel.subscribe( + deliveryMode: DeliveryMode = RedeliverOnStart, + subscriber: (S) -> Unit + ) = _internal(subscriptionLifecycleOwner, deliveryMode, { subscriber(it) }).toDisposable() /** diff --git a/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/rxjava2/MvRxTuples.kt b/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/rxjava2/MvRxTuples.kt index aac1b93ce..dc073fb56 100644 --- a/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/rxjava2/MvRxTuples.kt +++ b/mvrx-rxjava2/src/main/kotlin/com/airbnb/mvrx/rxjava2/MvRxTuples.kt @@ -6,4 +6,12 @@ internal data class MvRxTuple3(val a: A, val b: B, val c: C) internal data class MvRxTuple4(val a: A, val b: B, val c: C, val d: D) internal data class MvRxTuple5(val a: A, val b: B, val c: C, val d: D, val e: E) internal data class MvRxTuple6(val a: A, val b: B, val c: C, val d: D, val e: E, val f: F) -internal data class MvRxTuple7(val a: A, val b: B, val c: C, val d: D, val e: E, val f: F, val g: G) +internal data class MvRxTuple7( + val a: A, + val b: B, + val c: C, + val d: D, + val e: E, + val f: F, + val g: G +) diff --git a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/DisposableJobTest.kt b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/DisposableJobTest.kt index 1e4b98dab..c2dfdd698 100644 --- a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/DisposableJobTest.kt +++ b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/DisposableJobTest.kt @@ -39,4 +39,4 @@ class DisposableJobTest { job.complete() assert(disposable.isDisposed) } -} \ No newline at end of file +} diff --git a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt index 7d8c893a4..91dfc446f 100644 --- a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt +++ b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/TestLifecycleOwner.kt @@ -8,4 +8,4 @@ class TestLifecycleOwner : LifecycleOwner { private val _lifecycle = LifecycleRegistry(this) override fun getLifecycle(): LifecycleRegistry = _lifecycle -} \ No newline at end of file +} diff --git a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt index 43e7cc13c..b9030930f 100644 --- a/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt +++ b/mvrx-rxjava2/src/test/kotlin/com/airbnb/mvrx/ViewModelSubscriberTest.kt @@ -81,7 +81,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Success(Unit) else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Completable.create { emitter -> @@ -101,7 +102,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Fail(error) else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Completable.create { @@ -120,7 +122,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Success("Hello World") else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Single.create { emitter -> @@ -140,7 +143,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Fail(error) else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Single.create { @@ -159,7 +163,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Success("Hello World") else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Observable.just("Hello World").execute { copy(async = it) } @@ -177,7 +182,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> 1 3 -> 2 else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } setState { copy(foo = 1) } @@ -197,7 +203,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Fail(error) else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Observable.create { @@ -216,7 +223,8 @@ class ViewModelTestViewModel(initialState: ViewModelTestState) : BaseMvRxViewMod 2 -> Loading() 3 -> Success("Hello World!") else -> throw IllegalArgumentException("Unexpected call count $callCount") - }, it + }, + it ) } Observable.just("Hello World").execute(mapper = { "$it!" }) { copy(async = it) } @@ -692,10 +700,13 @@ class ViewModelSubscriberTest : BaseTest() { var callCount = 0 val success = "Hello World" val fail = IllegalStateException("Uh oh") - viewModel._internalSF(owner, ViewModelTestState::async, onFail = { - callCount++ - assertEquals(fail, it) - }) { + viewModel._internalSF( + owner, ViewModelTestState::async, + onFail = { + callCount++ + assertEquals(fail, it) + } + ) { callCount++ assertEquals(success, it) } diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/CoroutinesStateStore.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/CoroutinesStateStore.kt index e6f204ffe..0a8a4b394 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/CoroutinesStateStore.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/CoroutinesStateStore.kt @@ -100,14 +100,14 @@ class CoroutinesStateStore( } override fun get(block: (S) -> Unit) { - withStateChannel.offer(block) + withStateChannel.trySend(block) if (MavericksTestOverrides.FORCE_SYNCHRONOUS_STATE_STORES) { flushQueuesOnceBlocking() } } override fun set(stateReducer: S.() -> S) { - setStateChannel.offer(stateReducer) + setStateChannel.trySend(stateReducer) if (MavericksTestOverrides.FORCE_SYNCHRONOUS_STATE_STORES) { flushQueuesOnceBlocking() } diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/FlowExtensions.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/FlowExtensions.kt index 129a5a7ad..a3ba5cb7f 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/FlowExtensions.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/FlowExtensions.kt @@ -46,7 +46,11 @@ internal fun Flow.collectLatest( } @Suppress("EXPERIMENTAL_API_USAGE") -internal fun Flow.assertOneActiveSubscription(lifecycleOwner: LifecycleOwner, activeSubscriptions: MutableSet, subscriptionId: String): Flow { +internal fun Flow.assertOneActiveSubscription( + lifecycleOwner: LifecycleOwner, + activeSubscriptions: MutableSet, + subscriptionId: String +): Flow { val observer = object : DefaultLifecycleObserver { override fun onCreate(owner: LifecycleOwner) { if (activeSubscriptions.contains(subscriptionId)) error(duplicateSubscriptionMessage(subscriptionId)) diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlow.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlow.kt index 42ff9bbbb..9ef6bca4b 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlow.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlow.kt @@ -46,6 +46,7 @@ fun Flow.flowWhenStarted(owner: LifecycleOwner): Flow = flow { onReceive(startedChannel, { flowChannel.cancel(); isClosed = true }) { started = it if (flowValue !== null) { + @Suppress("UNCHECKED_CAST") transform(it, flowValue as T) } } diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksTuples.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksTuples.kt index 5c9655b6f..cf815d90b 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksTuples.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksTuples.kt @@ -6,4 +6,12 @@ internal data class MavericksTuple3(val a: A, val b: B, val c: C) internal data class MavericksTuple4(val a: A, val b: B, val c: C, val d: D) internal data class MavericksTuple5(val a: A, val b: B, val c: C, val d: D, val e: E) internal data class MavericksTuple6(val a: A, val b: B, val c: C, val d: D, val e: E, val f: F) -internal data class MavericksTuple7(val a: A, val b: B, val c: C, val d: D, val e: E, val f: F, val g: G) +internal data class MavericksTuple7( + val a: A, + val b: B, + val c: C, + val d: D, + val e: E, + val f: F, + val g: G +) diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksView.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksView.kt index 9f52e0a9b..a8886b93c 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksView.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksView.kt @@ -112,7 +112,10 @@ interface MavericksView : LifecycleOwner { * @param action supports cooperative cancellation. The previous action will be cancelled if it is not completed before * the next one is emitted. */ - fun MavericksViewModel.onEach(deliveryMode: DeliveryMode = RedeliverOnStart, action: suspend (S) -> Unit) = + fun MavericksViewModel.onEach( + deliveryMode: DeliveryMode = RedeliverOnStart, + action: suspend (S) -> Unit + ) = _internal(subscriptionLifecycleOwner, deliveryMode, action) /** diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelConfig.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelConfig.kt index 37d71f48d..2c1b80c82 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelConfig.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelConfig.kt @@ -14,7 +14,6 @@ abstract class MavericksViewModelConfig( /** * The state store instance that will control the state of the ViewModel. */ - @InternalMavericksApi val stateStore: MavericksStateStore, /** * The coroutine scope that will be provided to the view model. diff --git a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt index dd7acd499..739a9a46a 100644 --- a/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt +++ b/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModelProvider.kt @@ -107,7 +107,9 @@ object MavericksViewModelProvider { } @Suppress("UNCHECKED_CAST") - private fun , S : MavericksState> Bundle.toStateRestorer(viewModelContext: ViewModelContext): StateRestorer { + private fun , S : MavericksState> Bundle.toStateRestorer( + viewModelContext: ViewModelContext + ): StateRestorer { val restoredArgs = get(KEY_MVRX_SAVED_ARGS) val restoredState = getBundle(KEY_MVRX_SAVED_INSTANCE_STATE) val restoredViewModelClass = getSerializable(KEY_MVRX_SAVED_VM_CLASS) as? Class diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/AsyncStateStoreTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/AsyncStateStoreTest.kt index ed7892b18..5123e5e31 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/AsyncStateStoreTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/AsyncStateStoreTest.kt @@ -9,7 +9,6 @@ import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeoutOrNull import org.junit.Assert.assertNull import org.junit.Test -import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds import kotlin.time.ExperimentalTime import kotlin.time.seconds @@ -23,8 +22,10 @@ class AsyncStateStoreTest { val store = CoroutinesStateStore(MavericksStateStoreTestState(), scope) val collectJob = scope.launch(Job()) { store.flow.collect() } scope.cancel() - assertNull(withTimeoutOrNull(seconds(1)) { - collectJob.join() - }) + assertNull( + withTimeoutOrNull(seconds(1)) { + collectJob.join() + } + ) } } diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/BaseViewModelTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/BaseViewModelTest.kt index e5d1e468b..b1569c8b1 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/BaseViewModelTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/BaseViewModelTest.kt @@ -17,4 +17,4 @@ class BaseViewModelTest : BaseTest() { viewModel.onCleared() assertFalse(viewModel.scope.isActive) } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/CoroutineStateStoreReplayTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/CoroutineStateStoreReplayTest.kt index 0e6b7c577..89d697ced 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/CoroutineStateStoreReplayTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/CoroutineStateStoreReplayTest.kt @@ -99,4 +99,4 @@ class CoroutineStateStoreReplayTest { scope.cancel() Unit } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/FragmentSubscriberTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/FragmentSubscriberTest.kt index 1ded6f26e..2eb23fe05 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/FragmentSubscriberTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/FragmentSubscriberTest.kt @@ -411,10 +411,12 @@ class FragmentSubscriberTest : BaseTest() { assertEquals(0, fragment.selectSubscribeCustomCallCount) // This will set foo to 1. See FragmentWithStateChangeDuringOrientationChange. - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val recreatedFragment = controller.mvRxFragment() @@ -442,10 +444,12 @@ class FragmentSubscriberTest : BaseTest() { assertEquals(-1, fragment.selectSubscribeCustomValue) assertEquals(0, fragment.selectSubscribeCustomCallCount) - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val recreatedFragment = controller.mvRxFragment() @@ -472,10 +476,12 @@ class FragmentSubscriberTest : BaseTest() { assertEquals(0, fragment.viewCreatedCustomCallCount) // This will set foo to 1. See FragmentWithStateChangeDuringOrientationChange. - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val recreatedFragment = controller.mvRxFragment() @@ -500,10 +506,12 @@ class FragmentSubscriberTest : BaseTest() { assertEquals(1, fragment.viewCreatedSubscribeCallCount) assertEquals(0, fragment.viewCreatedCustomCallCount) - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val recreatedFragment = controller.mvRxFragment() @@ -717,7 +725,8 @@ class FragmentSubscriberTest : BaseTest() { fun testCustom() { val (controller, fragment) = createFragmentInTestActivity() fragment.setFoo(1) - assertEquals(1, fragment.selectSubscribeCustomCallCount + assertEquals( + 1, fragment.selectSubscribeCustomCallCount ) controller.pause() diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksExtensionsKtTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksExtensionsKtTest.kt index 3e21bbcb7..9664b01b2 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksExtensionsKtTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksExtensionsKtTest.kt @@ -18,4 +18,4 @@ class MavericksExtensionsKtTest : BaseTest() { val args = value.asMavericksArgs() assertEquals(true, args.getSerializable(Mavericks.KEY_ARG)) } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt index b8beefce8..fc4e5df51 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksLifecycleAwareFlowKtTest.kt @@ -147,4 +147,4 @@ class MavericksLifecycleAwareFlowKtTest : BaseTest() { flowOf(1).flowWhenStarted(owner).collect() } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksMutabilityHelperKtTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksMutabilityHelperKtTest.kt index 1b8f2a966..7daba8d9b 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksMutabilityHelperKtTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksMutabilityHelperKtTest.kt @@ -13,7 +13,6 @@ class MavericksMutabilityHelperKtTest { } data class TestDataClass( - internal val foo: Int + internal val foo: Int ) } - diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksViewModelTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksViewModelTest.kt index e461e4ab4..c9492bd6a 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksViewModelTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/MavericksViewModelTest.kt @@ -28,7 +28,7 @@ class MavericksViewModelTestViewModel : MavericksViewModel (suspend () -> T).executePublic ( + fun (suspend () -> T).executePublic( dispatcher: CoroutineDispatcher? = null, retainValue: KProperty1>? = null, reducer: BaseMavericksViewModelTestState.(Async) -> BaseMavericksViewModelTestState @@ -182,7 +182,7 @@ class MavericksViewModelTest : BaseTest() { fun testAwaitState() = runInViewModelBlocking( BaseMavericksViewModelTestState(int = 0), BaseMavericksViewModelTestState(int = 1), - ) { + ) { setInt(1) val state = awaitState() assertEquals(1, state.int) @@ -204,4 +204,4 @@ class MavericksViewModelTest : BaseTest() { companion object { private val exception = IllegalStateException("Fail!") } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/MvRxMutabilityHelperKtTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/MvRxMutabilityHelperKtTest.kt index 48b9d9cae..67636d9c8 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/MvRxMutabilityHelperKtTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/MvRxMutabilityHelperKtTest.kt @@ -13,7 +13,6 @@ class MvRxMutabilityHelperKtTest { } data class TestDataClass( - internal val foo: Int + internal val foo: Int ) } - diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/PersistedStateTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/PersistedStateTest.kt index aeb3b955c..d68c11e2e 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/PersistedStateTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/PersistedStateTest.kt @@ -210,7 +210,9 @@ class PersistedStateTest : BaseTest() { @Test fun testParcelableMapWithChangedValue() { - data class State2(@PersistState val data: Map = mapOf("foo" to ParcelableClass(count = 2))) : MavericksState + data class State2( + @PersistState val data: Map = mapOf("foo" to ParcelableClass(count = 2)) + ) : MavericksState val bundle = PersistStateTestHelpers.persistState(State2(mapOf("foo" to ParcelableClass(3)))) val state = PersistStateTestHelpers.restorePersistedState(bundle, State2()) @@ -219,7 +221,9 @@ class PersistedStateTest : BaseTest() { @Test(expected = IllegalStateException::class) fun testNonParcelableMap() { - data class State2(@PersistState val data: Map = mapOf("foo" to Mockito.mock(Context::class.java))) : MavericksState + data class State2( + @PersistState val data: Map = mapOf("foo" to Mockito.mock(Context::class.java)) + ) : MavericksState PersistStateTestHelpers.persistState(State2()) } diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateAfterScopeCancellationTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateAfterScopeCancellationTest.kt index 2735a355c..b3c41b9a0 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateAfterScopeCancellationTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateAfterScopeCancellationTest.kt @@ -27,4 +27,4 @@ class SetStateWithStateAfterScopeCancellationTest : BaseTest() { val store = CoroutinesStateStore(State(foo = 0), scope) store.get { } } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateOrderingTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateOrderingTest.kt index eb7b5640e..4ef203e9c 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateOrderingTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/SetStateWithStateOrderingTest.kt @@ -171,4 +171,4 @@ class SetStateWithStateOrderingTest : MavericksViewModel(Ordering } assertEquals(expectedCalls.toList(), calls.toList()) } -} \ No newline at end of file +} diff --git a/mvrx/src/test/kotlin/com/airbnb/mvrx/ViewModelStoreTest.kt b/mvrx/src/test/kotlin/com/airbnb/mvrx/ViewModelStoreTest.kt index a6145046e..2bb9a479f 100644 --- a/mvrx/src/test/kotlin/com/airbnb/mvrx/ViewModelStoreTest.kt +++ b/mvrx/src/test/kotlin/com/airbnb/mvrx/ViewModelStoreTest.kt @@ -110,10 +110,12 @@ class ViewModelStoreTest : BaseTest() { fun testActivityViewModelRetainedAcrossConfigurationChanges() { val (controller, fragment) = createFragment() fragment.viewModelActivity.setCount(2) - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val recreatedFragment = controller.mvRxFragment() assertNotEquals(fragment, recreatedFragment) withState(recreatedFragment.viewModelActivity) { state -> @@ -127,10 +129,12 @@ class ViewModelStoreTest : BaseTest() { fun testPersistedStateForActivityViewModelWhenSetFromFragmentArgsAfterConfigurationChange() { val (controller, fragment) = createFragment(args = ViewModelStoreTestArgs(3)) fragment.viewModelActivity.setCount(2) - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val bundleTwo = Bundle() controller.saveInstanceState(bundleTwo) @@ -171,10 +175,12 @@ class ViewModelStoreTest : BaseTest() { fun testFragmentViewModelRetainedAcrossConfigurationChanges() { val (controller, fragment) = createFragment() fragment.viewModelFragment.setCount(2) - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val recreatedFragment = controller.mvRxFragment() assertNotEquals(fragment, recreatedFragment) withState(recreatedFragment.viewModelFragment) { state -> @@ -188,10 +194,12 @@ class ViewModelStoreTest : BaseTest() { fun testPersistedStateForFragmentViewModelWhenSetFromFragmentArgsAfterConfigurationChange() { val (controller, fragment) = createFragment(args = ViewModelStoreTestArgs(3)) fragment.viewModelFragment.setCount(2) - controller.configurationChange(Configuration().apply { - setToDefaults() - this.orientation = Configuration.ORIENTATION_LANDSCAPE - }) + controller.configurationChange( + Configuration().apply { + setToDefaults() + this.orientation = Configuration.ORIENTATION_LANDSCAPE + } + ) val bundleTwo = Bundle() controller.saveInstanceState(bundleTwo) diff --git a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleMockBehaviorTest.kt b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleMockBehaviorTest.kt index 3deb99528..c20931776 100644 --- a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleMockBehaviorTest.kt +++ b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleMockBehaviorTest.kt @@ -1,7 +1,6 @@ package com.airbnb.android.mvrx.test import com.airbnb.mvrx.Mavericks -import com.airbnb.mvrx.MvRx import com.airbnb.mvrx.test.MvRxTestRule import org.junit.Rule import org.junit.Test diff --git a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverDisabled.kt b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverDisabled.kt index e91b805aa..9cb507d06 100644 --- a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverDisabled.kt +++ b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverDisabled.kt @@ -16,4 +16,4 @@ class MvRxTestRuleTestLifecycleAwareObserverDisabled { view.doSomething() Assert.assertEquals(2, view.subscribeCallCount) } -} \ No newline at end of file +} diff --git a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverEnabled.kt b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverEnabled.kt index b28c8a1a7..bc9eed518 100644 --- a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverEnabled.kt +++ b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/MvRxTestRuleTestLifecycleAwareObserverEnabled.kt @@ -14,4 +14,4 @@ class MvRxTestRuleTestLifecycleAwareObserverEnabled { val view = TestRuleView() Assert.assertEquals(0, view.subscribeCallCount) } -} \ No newline at end of file +} diff --git a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleView.kt b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleView.kt index 8c239de1e..a3f5d8aad 100644 --- a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleView.kt +++ b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleView.kt @@ -19,4 +19,4 @@ class TestRuleView : BaseMvRxFragment() { override fun invalidate() {} fun doSomething() = viewModel.doSomething() -} \ No newline at end of file +} diff --git a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleViewModel.kt b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleViewModel.kt index c6078464b..f8584eabb 100644 --- a/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleViewModel.kt +++ b/testing/src/test/kotlin/com/airbnb/android/mvrx/test/TestRuleViewModel.kt @@ -4,7 +4,7 @@ import com.airbnb.mvrx.BaseMvRxViewModel import com.airbnb.mvrx.MavericksState data class TestRuleState(val foo: String = "hello") : MavericksState -class TestRuleViewModel() : BaseMvRxViewModel(TestRuleState()) { +class TestRuleViewModel : BaseMvRxViewModel(TestRuleState()) { var subscribeCallCount = 0 var setStateCount = 0 @@ -20,4 +20,3 @@ class TestRuleViewModel() : BaseMvRxViewModel(TestRuleState()) { copy(foo = "$foo!") } } - diff --git a/todomvrx/src/test/java/com/airbnb/mvrx/todomvrx/TasksViewModelTest.kt b/todomvrx/src/test/java/com/airbnb/mvrx/todomvrx/TasksViewModelTest.kt index 8a1a724f6..ded525f3a 100644 --- a/todomvrx/src/test/java/com/airbnb/mvrx/todomvrx/TasksViewModelTest.kt +++ b/todomvrx/src/test/java/com/airbnb/mvrx/todomvrx/TasksViewModelTest.kt @@ -279,4 +279,4 @@ class TasksViewModelTest { @ClassRule val mvrxTestRule = MvRxTestRule() } -} \ No newline at end of file +}