From 126e6b6ba710cb5fd6a178c6e6e10b023694b09d Mon Sep 17 00:00:00 2001 From: Mikhail Fedotov Date: Wed, 23 Oct 2024 23:10:32 +0300 Subject: [PATCH] Optimize imports --- README.md | 3 +-- docs/pages/persistence.md | 2 +- .../nsk/kstatemachine/persistence/RestoreByRecordedEvents.kt | 1 - .../commonMain/kotlin/ru/nsk/samples/ComplexSyntaxSample.kt | 1 - .../ru/nsk/samples/SerializationEventRecordingSample.kt | 5 ++++- .../kotlin/ru/nsk/kstatemachine/coroutines/CoroutinesTest.kt | 3 +-- .../kotlin/ru/nsk/kstatemachine/event/FinishedEventTest.kt | 3 --- .../ru/nsk/kstatemachine/persistence/EventRecorderTest.kt | 1 - .../persistence/RecordedEventsSerializerTest.kt | 3 --- .../kotlin/ru/nsk/kstatemachine/state/ChoiceStateTest.kt | 1 - .../commonTest/kotlin/ru/nsk/kstatemachine/state/UndoTest.kt | 3 ++- .../visitors/export/ExportPlantUmlVisitorTest.kt | 1 - 12 files changed, 9 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 719787b..8539f4c 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ state (like stack based FSMs do) transitions * **[Export](https://kstatemachine.github.io/kstatemachine/pages/export.html)** state machine structure to [PlantUML](https://plantuml.com/) and [Mermaid](https://mermaid.js.org/) diagrams -* **[Persist (serialize)](https://kstatemachine.github.io/kstatemachine/pages/persistence.html)** state machine's +* **[Persist (serialize)](https://kstatemachine.github.io/kstatemachine/pages/persistence.html)** state machine's active configuration and restore it later. Built-in `kotlinx.serialization` support. * **[Testable](https://kstatemachine.github.io/kstatemachine/pages/testing.html)** - run state machine from specified @@ -223,7 +223,6 @@ dependencies { // multiplatform artifacts, where is a library version. implementation("io.github.nsk90:kstatemachine:") implementation("io.github.nsk90:kstatemachine-coroutines:") - implementation("io.github.nsk90:kstatemachine-serialization:") } ``` diff --git a/docs/pages/persistence.md b/docs/pages/persistence.md index 73b6a42..2930e0d 100644 --- a/docs/pages/persistence.md +++ b/docs/pages/persistence.md @@ -1,6 +1,6 @@ --- layout: page -title: Persistence +title: Persistence (Serialization) --- # Persistence (Serialization) diff --git a/kstatemachine/src/commonMain/kotlin/ru/nsk/kstatemachine/persistence/RestoreByRecordedEvents.kt b/kstatemachine/src/commonMain/kotlin/ru/nsk/kstatemachine/persistence/RestoreByRecordedEvents.kt index 15496e6..17be7e9 100644 --- a/kstatemachine/src/commonMain/kotlin/ru/nsk/kstatemachine/persistence/RestoreByRecordedEvents.kt +++ b/kstatemachine/src/commonMain/kotlin/ru/nsk/kstatemachine/persistence/RestoreByRecordedEvents.kt @@ -8,7 +8,6 @@ package ru.nsk.kstatemachine.persistence import ru.nsk.kstatemachine.event.SerializableGeneratedEvent -import ru.nsk.kstatemachine.event.StartEvent import ru.nsk.kstatemachine.statemachine.* import ru.nsk.kstatemachine.visitors.structureHashCode diff --git a/samples/src/commonMain/kotlin/ru/nsk/samples/ComplexSyntaxSample.kt b/samples/src/commonMain/kotlin/ru/nsk/samples/ComplexSyntaxSample.kt index 710942a..198cd1d 100644 --- a/samples/src/commonMain/kotlin/ru/nsk/samples/ComplexSyntaxSample.kt +++ b/samples/src/commonMain/kotlin/ru/nsk/samples/ComplexSyntaxSample.kt @@ -8,7 +8,6 @@ package ru.nsk.samples import kotlinx.coroutines.runBlocking -import ru.nsk.kstatemachine.statemachine.StateMachine import ru.nsk.kstatemachine.event.Event import ru.nsk.kstatemachine.state.* import ru.nsk.kstatemachine.statemachine.* diff --git a/samples/src/commonMain/kotlin/ru/nsk/samples/SerializationEventRecordingSample.kt b/samples/src/commonMain/kotlin/ru/nsk/samples/SerializationEventRecordingSample.kt index 878287f..47898f8 100644 --- a/samples/src/commonMain/kotlin/ru/nsk/samples/SerializationEventRecordingSample.kt +++ b/samples/src/commonMain/kotlin/ru/nsk/samples/SerializationEventRecordingSample.kt @@ -14,7 +14,10 @@ import kotlinx.coroutines.runBlocking import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json -import kotlinx.serialization.modules.* +import kotlinx.serialization.modules.SerializersModule +import kotlinx.serialization.modules.plus +import kotlinx.serialization.modules.polymorphic +import kotlinx.serialization.modules.subclass import ru.nsk.kstatemachine.event.Event import ru.nsk.kstatemachine.persistence.RecordedEvents import ru.nsk.kstatemachine.persistence.restoreByRecordedEvents diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/coroutines/CoroutinesTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/coroutines/CoroutinesTest.kt index 6768de4..23687d5 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/coroutines/CoroutinesTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/coroutines/CoroutinesTest.kt @@ -17,16 +17,15 @@ import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.take import ru.nsk.kstatemachine.SecondEvent import ru.nsk.kstatemachine.SwitchEvent -import ru.nsk.kstatemachine.statemachine.StateMachineNotification.* import ru.nsk.kstatemachine.event.StartEvent import ru.nsk.kstatemachine.mockkCallbacks import ru.nsk.kstatemachine.state.* import ru.nsk.kstatemachine.statemachine.* +import ru.nsk.kstatemachine.statemachine.StateMachineNotification.* import ru.nsk.kstatemachine.transition.onTriggered import ru.nsk.kstatemachine.transition.stay import kotlin.coroutines.EmptyCoroutineContext - @OptIn(ExperimentalCoroutinesApi::class, DelicateCoroutinesApi::class) class CoroutinesTest : StringSpec({ /** Coroutines manipulations like withContext or launch from coroutineScope make test fail. */ diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/event/FinishedEventTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/event/FinishedEventTest.kt index ca4c516..bb8d507 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/event/FinishedEventTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/event/FinishedEventTest.kt @@ -13,10 +13,7 @@ import io.mockk.verifySequence import ru.nsk.kstatemachine.* import ru.nsk.kstatemachine.state.* import ru.nsk.kstatemachine.statemachine.StateMachine -import ru.nsk.kstatemachine.statemachine.processEventBlocking -import ru.nsk.kstatemachine.transition.EventAndArgument import ru.nsk.kstatemachine.transition.onTriggered -import ru.nsk.kstatemachine.visitors.export.exportToPlantUml class FinishedEventTest : StringSpec({ CoroutineStarterType.entries.forEach { coroutineStarterType -> diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/persistence/EventRecorderTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/persistence/EventRecorderTest.kt index 278f9d0..df134ae 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/persistence/EventRecorderTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/persistence/EventRecorderTest.kt @@ -15,7 +15,6 @@ import io.kotest.matchers.collections.shouldContainInOrder import io.kotest.matchers.collections.shouldHaveSize import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeInstanceOf -import io.kotest.mpp.start import ru.nsk.kstatemachine.* import ru.nsk.kstatemachine.event.FinishedEvent import ru.nsk.kstatemachine.event.SerializableGeneratedEvent diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/serialization/persistence/RecordedEventsSerializerTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/serialization/persistence/RecordedEventsSerializerTest.kt index c16765f..a706f0d 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/serialization/persistence/RecordedEventsSerializerTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/serialization/persistence/RecordedEventsSerializerTest.kt @@ -14,8 +14,6 @@ import io.kotest.matchers.types.shouldBeInstanceOf import kotlinx.coroutines.CoroutineScope import kotlinx.serialization.KSerializer import kotlinx.serialization.Serializable -import kotlinx.serialization.builtins.nullable -import kotlinx.serialization.builtins.serializer import kotlinx.serialization.descriptors.buildClassSerialDescriptor import kotlinx.serialization.descriptors.element import kotlinx.serialization.encodeToString @@ -27,7 +25,6 @@ import kotlinx.serialization.modules.polymorphic import kotlinx.serialization.modules.subclass import ru.nsk.kstatemachine.event.DataEvent import ru.nsk.kstatemachine.event.Event -import ru.nsk.kstatemachine.event.SerializableGeneratedEvent.EventType import ru.nsk.kstatemachine.persistence.RecordedEvents import ru.nsk.kstatemachine.persistence.restoreByRecordedEvents import ru.nsk.kstatemachine.state.* diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/ChoiceStateTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/ChoiceStateTest.kt index 5840971..cd435a7 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/ChoiceStateTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/ChoiceStateTest.kt @@ -13,7 +13,6 @@ import io.kotest.matchers.shouldBe import io.mockk.verifySequence import ru.nsk.kstatemachine.* import ru.nsk.kstatemachine.event.DataEvent -import ru.nsk.kstatemachine.event.defaultDataExtractor import ru.nsk.kstatemachine.state.ChoiceStateTestData.IntEvent import ru.nsk.kstatemachine.state.ChoiceStateTestData.State1 import ru.nsk.kstatemachine.state.ChoiceStateTestData.State2 diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/UndoTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/UndoTest.kt index 94b2755..9016f1a 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/UndoTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/state/UndoTest.kt @@ -19,7 +19,8 @@ import ru.nsk.kstatemachine.event.UndoEvent import ru.nsk.kstatemachine.event.WrappedEvent import ru.nsk.kstatemachine.state.UndoTestData.SwitchDataEvent import ru.nsk.kstatemachine.statemachine.* -import ru.nsk.kstatemachine.statemachine.StateMachine.* +import ru.nsk.kstatemachine.statemachine.StateMachine.IgnoredEventHandler +import ru.nsk.kstatemachine.statemachine.StateMachine.Logger import ru.nsk.kstatemachine.transition.unwrappedArgument import ru.nsk.kstatemachine.transition.unwrappedEvent diff --git a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/visitors/export/ExportPlantUmlVisitorTest.kt b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/visitors/export/ExportPlantUmlVisitorTest.kt index 86cb288..535e06e 100644 --- a/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/visitors/export/ExportPlantUmlVisitorTest.kt +++ b/tests/src/commonTest/kotlin/ru/nsk/kstatemachine/visitors/export/ExportPlantUmlVisitorTest.kt @@ -15,7 +15,6 @@ import io.kotest.data.table import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldNotBeInstanceOf import ru.nsk.kstatemachine.* -import ru.nsk.kstatemachine.metainfo.UmlMetaInfo import ru.nsk.kstatemachine.metainfo.buildUmlMetaInfo import ru.nsk.kstatemachine.state.* import ru.nsk.kstatemachine.statemachine.StateMachine