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 TypeEvaluation")
class TypeEvaluationTest {

  @Test
  @DisplayName("Test de base - enum peut être utilisé")
  void testEnumUtilisable() {
    assertThat(TypeEvaluation.SATISFACTION_BENEFICIAIRE).isNotNull();
    assertThat(TypeEvaluation.EVALUATION_IMPACT).isNotNull();
  }

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

    @Test
    @DisplayName("Test toutes les valeurs enum")
    void testToutesValeurs() {
      TypeEvaluation[] values = TypeEvaluation.values();
      assertThat(values).hasSize(6);
      assertThat(values).containsExactly(
          TypeEvaluation.SATISFACTION_BENEFICIAIRE,
          TypeEvaluation.EVALUATION_PROPOSANT,
          TypeEvaluation.EVALUATION_PROCESSUS,
          TypeEvaluation.SUIVI_POST_AIDE,
          TypeEvaluation.EVALUATION_IMPACT,
          TypeEvaluation.RETOUR_EXPERIENCE);
    }

    @Test
    @DisplayName("Test valueOf - toutes les constantes")
    void testValueOf() {
      assertThat(TypeEvaluation.valueOf("SATISFACTION_BENEFICIAIRE")).isEqualTo(TypeEvaluation.SATISFACTION_BENEFICIAIRE);
      assertThat(TypeEvaluation.valueOf("EVALUATION_PROPOSANT")).isEqualTo(TypeEvaluation.EVALUATION_PROPOSANT);
      assertThat(TypeEvaluation.valueOf("EVALUATION_PROCESSUS")).isEqualTo(TypeEvaluation.EVALUATION_PROCESSUS);
      assertThat(TypeEvaluation.valueOf("SUIVI_POST_AIDE")).isEqualTo(TypeEvaluation.SUIVI_POST_AIDE);
      assertThat(TypeEvaluation.valueOf("EVALUATION_IMPACT")).isEqualTo(TypeEvaluation.EVALUATION_IMPACT);
      assertThat(TypeEvaluation.valueOf("RETOUR_EXPERIENCE")).isEqualTo(TypeEvaluation.RETOUR_EXPERIENCE);

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

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

    @Test
    @DisplayName("Test getLibelle valeurs exactes")
    void testGetLibelleValeursExactes() {
      assertThat(TypeEvaluation.SATISFACTION_BENEFICIAIRE.getLibelle()).isEqualTo("Satisfaction du bénéficiaire");
      assertThat(TypeEvaluation.EVALUATION_IMPACT.getLibelle()).isEqualTo("Évaluation d'impact");
      assertThat(TypeEvaluation.RETOUR_EXPERIENCE.getLibelle()).isEqualTo("Retour d'expérience");
    }

    @Test
    @DisplayName("Test name()")
    void testName() {
      assertThat(TypeEvaluation.SATISFACTION_BENEFICIAIRE.name()).isEqualTo("SATISFACTION_BENEFICIAIRE");
      assertThat(TypeEvaluation.EVALUATION_IMPACT.name()).isEqualTo("EVALUATION_IMPACT");
    }
  }
}
