package com.cameleer.server.core.runtime;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class DeploymentStrategyTest {

    @Test
    void fromWire_knownValues() {
        assertThat(DeploymentStrategy.fromWire("blue-green")).isEqualTo(DeploymentStrategy.BLUE_GREEN);
        assertThat(DeploymentStrategy.fromWire("rolling")).isEqualTo(DeploymentStrategy.ROLLING);
    }

    @Test
    void fromWire_caseInsensitiveAndTrims() {
        assertThat(DeploymentStrategy.fromWire("BLUE-GREEN")).isEqualTo(DeploymentStrategy.BLUE_GREEN);
        assertThat(DeploymentStrategy.fromWire("  Rolling  ")).isEqualTo(DeploymentStrategy.ROLLING);
    }

    @Test
    void fromWire_unknownOrNullFallsBackToBlueGreen() {
        assertThat(DeploymentStrategy.fromWire(null)).isEqualTo(DeploymentStrategy.BLUE_GREEN);
        assertThat(DeploymentStrategy.fromWire("")).isEqualTo(DeploymentStrategy.BLUE_GREEN);
        assertThat(DeploymentStrategy.fromWire("canary")).isEqualTo(DeploymentStrategy.BLUE_GREEN);
    }

    @Test
    void toWire_roundTrips() {
        for (DeploymentStrategy s : DeploymentStrategy.values()) {
            assertThat(DeploymentStrategy.fromWire(s.toWire())).isEqualTo(s);
        }
    }
}
