package dev.lions.unionflow.server.entity.gouvernance;

import dev.lions.unionflow.server.api.enums.gouvernance.NiveauEchelon;
import dev.lions.unionflow.server.entity.Organisation;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.UUID;

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

@DisplayName("EchelonOrganigramme")
class EchelonOrganigrammeTest {

    private static Organisation newOrganisation() {
        Organisation o = new Organisation();
        o.setId(UUID.randomUUID());
        o.setNom("Org");
        o.setTypeOrganisation("X");
        o.setStatut("ACTIVE");
        o.setEmail("org@test.com");
        return o;
    }

    @Test
    @DisplayName("getters/setters")
    void gettersSetters() {
        EchelonOrganigramme e = new EchelonOrganigramme();
        e.setOrganisation(newOrganisation());
        e.setNiveau(NiveauEchelon.NATIONAL);
        e.setDesignation("Direction générale");
        e.setZoneGeographiqueOuDelegation("Siège");

        assertThat(e.getNiveau()).isEqualTo(NiveauEchelon.NATIONAL);
        assertThat(e.getDesignation()).isEqualTo("Direction générale");
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        Organisation o = newOrganisation();
        EchelonOrganigramme a = new EchelonOrganigramme();
        a.setId(id);
        a.setOrganisation(o);
        a.setNiveau(NiveauEchelon.NATIONAL);
        a.setDesignation("D");
        EchelonOrganigramme b = new EchelonOrganigramme();
        b.setId(id);
        b.setOrganisation(o);
        b.setNiveau(NiveauEchelon.NATIONAL);
        b.setDesignation("D");
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        EchelonOrganigramme e = new EchelonOrganigramme();
        e.setOrganisation(newOrganisation());
        e.setNiveau(NiveauEchelon.NATIONAL);
        e.setDesignation("X");
        assertThat(e.toString()).isNotNull().isNotEmpty();
    }
}
