import com.correx.core.validation.approval.ApprovalTrigger
import com.correx.core.validation.model.ValidationIssue
import com.correx.core.validation.model.ValidationReport
import com.correx.core.validation.model.ValidationSection
import com.correx.core.validation.model.ValidationSeverity
import org.junit.jupiter.api.Assertions.assertNotNull
import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.Test

class ApprovalTriggerTest {

    private val trigger = ApprovalTrigger()

    @Test
    fun `should trigger approval on error`() {

        val report = ValidationReport(
            sections = listOf(
                ValidationSection(
                    name = "graph",
                    issues = listOf(
                        ValidationIssue(
                            code = "GRAPH_DANGLING_TRANSITION",
                            message = "error",
                            severity = ValidationSeverity.ERROR,
                        ),
                    ),
                ),
            ),
        )

        val result = trigger.evaluate(report)

        assertNotNull(result)
    }

    @Test
    fun `should not trigger approval on clean report`() {

        val report = ValidationReport(
            sections = listOf(
                ValidationSection("graph", emptyList()),
            ),
        )

        val result = trigger.evaluate(report)

        assertNull(result)
    }
}
