package dev.lions.unionflow.server.entity;

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

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class ReferentielComptableTest {

  @Test
  @DisplayName("defaultFor null retourne SYSCOHADA")
  void defaultForNullReturnsSyscohada() {
    assertThat(ReferentielComptable.defaultFor(null)).isEqualTo(ReferentielComptable.SYSCOHADA);
  }

  @Test
  @DisplayName("defaultFor MUTUELLE_SANTE retourne SYCEBNL")
  void defaultForMutuelleSanteReturnsSycebnl() {
    assertThat(ReferentielComptable.defaultFor("MUTUELLE_SANTE"))
        .isEqualTo(ReferentielComptable.SYCEBNL);
  }

  @Test
  @DisplayName("defaultFor ASSOCIATION (case-insensitive) retourne SYCEBNL")
  void defaultForAssociationCaseInsensitiveReturnsSycebnl() {
    assertThat(ReferentielComptable.defaultFor("association")).isEqualTo(ReferentielComptable.SYCEBNL);
    assertThat(ReferentielComptable.defaultFor("Association")).isEqualTo(ReferentielComptable.SYCEBNL);
    assertThat(ReferentielComptable.defaultFor("ASSOCIATION")).isEqualTo(ReferentielComptable.SYCEBNL);
  }

  @Test
  @DisplayName("defaultFor LIONS_CLUB / ONG / FONDATION / SYNDICAT / ORDRE_PROFESSIONNEL retourne SYCEBNL")
  void defaultForBNLEntitiesReturnsSycebnl() {
    for (String t : new String[] {
        "LIONS_CLUB", "ONG", "FONDATION", "SYNDICAT", "ORDRE_PROFESSIONNEL", "PROJET_DEVELOPPEMENT"
    }) {
      assertThat(ReferentielComptable.defaultFor(t))
          .as("type=%s", t)
          .isEqualTo(ReferentielComptable.SYCEBNL);
    }
  }

  @Test
  @DisplayName("defaultFor SFD_TIER_1 retourne PCSFD_UMOA")
  void defaultForSfdTier1ReturnsPcsfd() {
    assertThat(ReferentielComptable.defaultFor("SFD_TIER_1"))
        .isEqualTo(ReferentielComptable.PCSFD_UMOA);
    assertThat(ReferentielComptable.defaultFor("SFD_CATEGORIE_III"))
        .isEqualTo(ReferentielComptable.PCSFD_UMOA);
  }

  @Test
  @DisplayName("defaultFor type non listé retourne SYSCOHADA")
  void defaultForUnknownReturnsSyscohada() {
    assertThat(ReferentielComptable.defaultFor("MUTUELLE_EPARGNE_CREDIT"))
        .isEqualTo(ReferentielComptable.SYSCOHADA);
    assertThat(ReferentielComptable.defaultFor("COOPERATIVE_COMMERCIALE"))
        .isEqualTo(ReferentielComptable.SYSCOHADA);
    assertThat(ReferentielComptable.defaultFor("INCONNU_XYZ"))
        .isEqualTo(ReferentielComptable.SYSCOHADA);
  }
}
