package com.correx.testing.fixtures.kernel

import com.correx.core.events.types.SessionId
import com.correx.core.sessions.Session
import com.correx.core.sessions.SessionState
import com.correx.core.sessions.SessionStatus
import kotlinx.datetime.Clock

class MockSessionRepository {
    private val sessions = mutableMapOf<SessionId, Session>()
    fun setSession(sessionId: SessionId, session: Session) {
        sessions[sessionId] = session
    }

    fun getSession(sessionId: SessionId): Session {
        return sessions[sessionId] ?: Session(
            sessionId = sessionId,
            state = SessionState(
                status = SessionStatus.ACTIVE,
                createdAt = Clock.System.now(),
                updatedAt = Clock.System.now(),
                invalidTransitions = 0,
            ),
        )
    }

    fun rebuild(sessionId: SessionId): Session {
        return getSession(sessionId)
    }
}
