package dev.lions.unionflow.server.api.enums.solidarite;

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

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

@DisplayName("Tests pour StatutProposition")
class StatutPropositionTest {

  @Test
  @DisplayName("Test de base - enum peut être utilisé")
  void testEnumUtilisable() {
    assertThat(StatutProposition.ACTIVE).isNotNull();
    assertThat(StatutProposition.BROUILLON).isNotNull();
  }

  @Nested
  @DisplayName("Tests des valeurs enum")
  class TestsValeursEnum {

    @Test
    @DisplayName("Test toutes les valeurs enum")
    void testToutesValeurs() {
      StatutProposition[] values = StatutProposition.values();
      assertThat(values).hasSize(6);
      assertThat(values).containsExactly(
          StatutProposition.BROUILLON,
          StatutProposition.ACTIVE,
          StatutProposition.SUSPENDUE,
          StatutProposition.EXPIREE,
          StatutProposition.TERMINEE,
          StatutProposition.ANNULEE);
    }

    @Test
    @DisplayName("Test valueOf - toutes les constantes")
    void testValueOf() {
      assertThat(StatutProposition.valueOf("BROUILLON")).isEqualTo(StatutProposition.BROUILLON);
      assertThat(StatutProposition.valueOf("ACTIVE")).isEqualTo(StatutProposition.ACTIVE);
      assertThat(StatutProposition.valueOf("SUSPENDUE")).isEqualTo(StatutProposition.SUSPENDUE);
      assertThat(StatutProposition.valueOf("EXPIREE")).isEqualTo(StatutProposition.EXPIREE);
      assertThat(StatutProposition.valueOf("TERMINEE")).isEqualTo(StatutProposition.TERMINEE);
      assertThat(StatutProposition.valueOf("ANNULEE")).isEqualTo(StatutProposition.ANNULEE);

      assertThatThrownBy(() -> StatutProposition.valueOf("INEXISTANT"))
          .isInstanceOf(IllegalArgumentException.class);
    }

    @ParameterizedTest
    @EnumSource(StatutProposition.class)
    @DisplayName("Test getLibelle pour toutes les valeurs")
    void testGetLibelle(StatutProposition statut) {
      assertThat(statut.getLibelle()).isNotNull().isNotEmpty();
    }

    @Test
    @DisplayName("Test getLibelle valeurs exactes")
    void testGetLibelleValeursExactes() {
      assertThat(StatutProposition.BROUILLON.getLibelle()).isEqualTo("Brouillon");
      assertThat(StatutProposition.ACTIVE.getLibelle()).isEqualTo("Active");
      assertThat(StatutProposition.TERMINEE.getLibelle()).isEqualTo("Terminée");
      assertThat(StatutProposition.ANNULEE.getLibelle()).isEqualTo("Annulée");
    }

    @Test
    @DisplayName("Test name()")
    void testName() {
      assertThat(StatutProposition.ACTIVE.name()).isEqualTo("ACTIVE");
      assertThat(StatutProposition.EXPIREE.name()).isEqualTo("EXPIREE");
    }
  }
}
