package com.correx.testing.fixtures.transitions

import com.correx.core.events.types.StageId
import com.correx.core.events.types.TransitionId
import com.correx.core.transitions.evaluation.TransitionConditionEvaluator
import com.correx.core.transitions.graph.StageConfig
import com.correx.core.transitions.graph.TransitionEdge
import com.correx.core.transitions.graph.WorkflowGraph
import com.correx.core.transitions.resolution.DefaultTransitionResolver
import com.correx.core.transitions.resolution.TransitionResolver
import com.correx.testing.fixtures.WorkflowFixtures

object TransitionFixtures {

    fun alwaysTrueEvaluator(): TransitionConditionEvaluator {
        return TransitionConditionEvaluator { _, _ -> true }
    }

    fun simpleResolver(): TransitionResolver {
        return DefaultTransitionResolver(alwaysTrueEvaluator())
    }

    fun threeStageGraph(): WorkflowGraph {
        val a = StageId("A")
        val b = StageId("B")
        val c = StageId("C")

        return WorkflowGraph(
            id = "workflow-test",
            stages = mapOf(a to StageConfig(), b to StageConfig(), c to StageConfig()),
            transitions = setOf(
                TransitionEdge(id = TransitionId("t1"), from = a, to = b, condition = { true }),
                TransitionEdge(id = TransitionId("t2"), from = b, to = c, condition = { true }),
            ),
            start = a,
        )
    }

    fun simpleGraph(): WorkflowGraph = WorkflowFixtures.simpleGraph()
}
