package dev.lions.unionflow.server.entity;

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("ParametresCotisationOrganisation")
class ParametresCotisationOrganisationTest {

    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() {
        ParametresCotisationOrganisation p = new ParametresCotisationOrganisation();
        p.setOrganisation(newOrganisation());
        p.setMontantCotisationMensuelle(new BigDecimal("1000.00"));
        p.setMontantCotisationAnnuelle(new BigDecimal("12000.00"));
        p.setDevise("XOF");
        p.setDateDebutCalculAjour(LocalDate.now().minusMonths(1));
        p.setDelaiRetardAvantInactifJours(30);
        p.setCotisationObligatoire(true);

        assertThat(p.getMontantCotisationMensuelle()).isEqualByComparingTo("1000.00");
        assertThat(p.getMontantCotisationAnnuelle()).isEqualByComparingTo("12000.00");
        assertThat(p.getDevise()).isEqualTo("XOF");
        assertThat(p.getDelaiRetardAvantInactifJours()).isEqualTo(30);
    }

    @Test
    @DisplayName("isCalculAjourActive")
    void isCalculAjourActive() {
        ParametresCotisationOrganisation p = new ParametresCotisationOrganisation();
        p.setOrganisation(newOrganisation());
        p.setDevise("XOF");
        assertThat(p.isCalculAjourActive()).isFalse();
        p.setDateDebutCalculAjour(LocalDate.now());
        assertThat(p.isCalculAjourActive()).isTrue();
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        Organisation o = newOrganisation();
        ParametresCotisationOrganisation a = new ParametresCotisationOrganisation();
        a.setId(id);
        a.setOrganisation(o);
        a.setDevise("XOF");
        ParametresCotisationOrganisation b = new ParametresCotisationOrganisation();
        b.setId(id);
        b.setOrganisation(o);
        b.setDevise("XOF");
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        ParametresCotisationOrganisation p = new ParametresCotisationOrganisation();
        p.setOrganisation(newOrganisation());
        p.setDevise("XOF");
        assertThat(p.toString()).isNotNull().isNotEmpty();
    }
}
