7936251d6b
P2-1: Guard SessionId NPE with safe-call in SessionsReducer
P2-2: Remove 16 dead event classes + reducer branches; replace with live orchestration events in tests
P2-3: Standardize ChatInput divergences — guard CancelSession, single-arg ProtocolError
P2-4: Remove dead TuiToolRecord.diff and ToolDisplayStatus.REQUESTED
P2-5: Remove dead streamLive from SessionEventBridge
P2-6: Extract SessionsReducerContext data class for 6+ param method
P2-7: Replace StageId("none") sentinel with TypeId.NONE
P2-9: Add TypeId.random() factory on all type-alias IDs
P2-10: Add KDoc on schemaVersion documenting reserved-for-migration
P2-8: Verified RouterReducer string-template already correct (TypeId value class toString)
73 lines
2.2 KiB
Kotlin
73 lines
2.2 KiB
Kotlin
import com.correx.core.events.events.EventPayload
|
|
import com.correx.core.events.events.StageCompletedEvent
|
|
import com.correx.core.events.events.StageFailedEvent
|
|
import com.correx.core.events.events.TransitionExecutedEvent
|
|
import com.correx.core.events.serialization.JsonEventSerializer
|
|
import com.correx.core.events.types.SessionId
|
|
import com.correx.core.events.types.StageId
|
|
import com.correx.core.events.types.TransitionId
|
|
import org.junit.jupiter.api.Assertions.assertEquals
|
|
import org.junit.jupiter.api.Test
|
|
|
|
class TransitionEventSerializationTest {
|
|
|
|
@Test
|
|
fun `TransitionExecutedEvent serializes and deserializes (stage start equivalent)`() {
|
|
val event = TransitionExecutedEvent(
|
|
sessionId = SessionId("session-1"),
|
|
from = StageId("from"),
|
|
to = StageId("stage-a"),
|
|
transitionId = TransitionId("transition-a")
|
|
)
|
|
|
|
assertRoundTrip(event)
|
|
}
|
|
|
|
@Test
|
|
fun `StageCompletedEvent serializes and deserializes`() {
|
|
val event = StageCompletedEvent(
|
|
sessionId = SessionId("session-1"),
|
|
stageId = StageId("stage-a"),
|
|
transitionId = TransitionId("transition-a")
|
|
)
|
|
|
|
assertRoundTrip(event)
|
|
}
|
|
|
|
@Test
|
|
fun `StageFailedEvent serializes and deserializes`() {
|
|
val event = StageFailedEvent(
|
|
sessionId = SessionId("session-1"),
|
|
stageId = StageId("stage-a"),
|
|
transitionId = TransitionId("transition-a"),
|
|
reason = "boom"
|
|
)
|
|
|
|
assertRoundTrip(event)
|
|
}
|
|
|
|
@Test
|
|
fun `TransitionExecutedEvent serializes and deserializes`() {
|
|
val event = TransitionExecutedEvent(
|
|
sessionId = SessionId("session-1"),
|
|
from = StageId("stage-a"),
|
|
to = StageId("stage-b"),
|
|
transitionId = TransitionId("transition-a")
|
|
)
|
|
|
|
assertRoundTrip(event)
|
|
}
|
|
|
|
private inline fun <reified T : EventPayload> assertRoundTrip(
|
|
event: T
|
|
) {
|
|
val json = JsonEventSerializer()
|
|
val serialized = json.serialize(event)
|
|
|
|
val deserialized =
|
|
json.deserialize(serialized)
|
|
|
|
assertEquals(event, deserialized)
|
|
}
|
|
}
|