import com.correx.core.transitions.resolution.TransitionOrdering
import com.correx.core.validation.graph.GraphValidator
import com.correx.core.validation.model.ValidationContext
import com.correx.core.validation.pipeline.ValidationPipeline
import com.correx.core.validation.transition.TransitionValidator
import com.correx.testing.fixtures.WorkflowFixtures
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class ValidationReplayTest {

    @Test
    fun `validation must be replay deterministic`(): Unit = runBlocking {

        val graph = WorkflowFixtures.simpleGraph()

        val context = ValidationContext(graph)

        val pipeline = ValidationPipeline(
            listOf(
                GraphValidator(),
                TransitionValidator(TransitionOrdering.comparator)
            )
        )

        val results = (1..10).map {
            pipeline.validate(context)
        }

        assertTrue(results.distinct().size == 1)
    }
}
