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 TypeWorkflow")
class TypeWorkflowTest {

  @Test
  @DisplayName("Test de base - enum peut être utilisé")
  void testEnumUtilisable() {
    assertThat(TypeWorkflow.DEMANDE_AIDE).isNotNull();
    assertThat(TypeWorkflow.ADHESION).isNotNull();
  }

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

    @Test
    @DisplayName("Test toutes les valeurs enum")
    void testToutesValeurs() {
      TypeWorkflow[] values = TypeWorkflow.values();
      assertThat(values).hasSize(3);
      assertThat(values).containsExactly(
          TypeWorkflow.DEMANDE_AIDE,
          TypeWorkflow.ADHESION,
          TypeWorkflow.AUTRE);
    }

    @Test
    @DisplayName("Test valueOf - toutes les constantes")
    void testValueOf() {
      assertThat(TypeWorkflow.valueOf("DEMANDE_AIDE")).isEqualTo(TypeWorkflow.DEMANDE_AIDE);
      assertThat(TypeWorkflow.valueOf("ADHESION")).isEqualTo(TypeWorkflow.ADHESION);
      assertThat(TypeWorkflow.valueOf("AUTRE")).isEqualTo(TypeWorkflow.AUTRE);

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

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

    @Test
    @DisplayName("Test getLibelle valeurs exactes")
    void testGetLibelleValeursExactes() {
      assertThat(TypeWorkflow.DEMANDE_AIDE.getLibelle()).isEqualTo("Workflow demande d'aide solidarité");
      assertThat(TypeWorkflow.ADHESION.getLibelle()).isEqualTo("Workflow validation adhésion");
      assertThat(TypeWorkflow.AUTRE.getLibelle()).isEqualTo("Workflow personnalisé");
    }

    @Test
    @DisplayName("Test name()")
    void testName() {
      assertThat(TypeWorkflow.DEMANDE_AIDE.name()).isEqualTo("DEMANDE_AIDE");
      assertThat(TypeWorkflow.AUTRE.name()).isEqualTo("AUTRE");
    }
  }
}
