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

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

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.UUID;

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

@DisplayName("ProjetOng")
class ProjetOngTest {

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

    @Test
    @DisplayName("getters/setters")
    void gettersSetters() {
        ProjetOng p = new ProjetOng();
        p.setOrganisation(newOrganisation());
        p.setNomProjet("Projet santé");
        p.setDescriptionMandat("Description");
        p.setZoneGeographiqueIntervention("Abidjan");
        p.setBudgetPrevisionnel(new BigDecimal("5000000"));
        p.setDepensesReelles(new BigDecimal("1000000"));
        p.setStatut(StatutProjetOng.EN_COURS);
        p.setDateLancement(LocalDate.now());

        assertThat(p.getNomProjet()).isEqualTo("Projet santé");
        assertThat(p.getStatut()).isEqualTo(StatutProjetOng.EN_COURS);
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        Organisation o = newOrganisation();
        ProjetOng a = new ProjetOng();
        a.setId(id);
        a.setOrganisation(o);
        a.setNomProjet("P");
        a.setStatut(StatutProjetOng.EN_ETUDE);
        ProjetOng b = new ProjetOng();
        b.setId(id);
        b.setOrganisation(o);
        b.setNomProjet("P");
        b.setStatut(StatutProjetOng.EN_ETUDE);
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        ProjetOng p = new ProjetOng();
        p.setOrganisation(newOrganisation());
        p.setNomProjet("X");
        p.setStatut(StatutProjetOng.EN_ETUDE);
        assertThat(p.toString()).isNotNull().isNotEmpty();
    }
}
