package com.correx.testing.contracts.model.orchestration

import com.correx.core.events.execution.RetryPolicy
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows

class RetryPolicyTest {

    @Test
    fun `maxAttempts of zero throws IllegalArgumentException`() {
        assertThrows<IllegalArgumentException> {
            RetryPolicy(maxAttempts = 0)
        }
    }

    @Test
    fun `negative maxAttempts throws IllegalArgumentException`() {
        assertThrows<IllegalArgumentException> {
            RetryPolicy(maxAttempts = -1)
        }
    }

    @Test
    fun `maxAttempts of one is valid`() {
        val policy = RetryPolicy(maxAttempts = 1)
        assertEquals(1, policy.maxAttempts)
    }

    @Test
    fun `backoffMs defaults to one second`() {
        val policy = RetryPolicy(maxAttempts = 1)
        assertEquals(1_000L, policy.backoffMs)
    }

    @Test
    fun `backoffMs is stored when provided`() {
        val policy = RetryPolicy(maxAttempts = 3, backoffMs = 500L)
        assertEquals(500L, policy.backoffMs)
    }
}
