package com.correx.testing.fixtures.kernel

import com.correx.core.events.types.SessionId
import com.correx.core.sessions.SessionState
import com.correx.core.sessions.SessionStatus
import com.correx.core.sessions.projections.replay.EventReplayer
import kotlinx.datetime.Clock

class MockEventReplayer : EventReplayer<SessionState> {
    private val states = mutableMapOf<SessionId, SessionState>()

    fun setSessionState(sessionId: SessionId, state: SessionState) {
        states[sessionId] = state
    }

    override fun rebuild(sessionId: SessionId): SessionState {
        return states[sessionId] ?: SessionState(
            status = SessionStatus.ACTIVE,
            createdAt = Clock.System.now(),
            updatedAt = Clock.System.now(),
            invalidTransitions = 0
        )
    }
}
