package dev.lions.unionflow.server.entity;

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

import java.time.LocalDateTime;
import java.util.UUID;

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

@DisplayName("Favori")
class FavoriTest {

    @Test
    @DisplayName("getters/setters")
    void gettersSetters() {
        UUID userId = UUID.randomUUID();
        Favori f = new Favori();
        f.setUtilisateurId(userId);
        f.setTypeFavori("PAGE");
        f.setTitre("Tableau de bord");
        f.setDescription("Accès rapide");
        f.setUrl("/dashboard");
        f.setIcon("home");
        f.setCouleur("blue");
        f.setCategorie("Navigation");
        f.setOrdre(1);
        f.setNbVisites(10);
        f.setDerniereVisite(LocalDateTime.now());
        f.setEstPlusUtilise(false);

        assertThat(f.getUtilisateurId()).isEqualTo(userId);
        assertThat(f.getTypeFavori()).isEqualTo("PAGE");
        assertThat(f.getTitre()).isEqualTo("Tableau de bord");
        assertThat(f.getUrl()).isEqualTo("/dashboard");
        assertThat(f.getOrdre()).isEqualTo(1);
        assertThat(f.getNbVisites()).isEqualTo(10);
        assertThat(f.getEstPlusUtilise()).isFalse();
    }

    @Test
    @DisplayName("ordre et nbVisites par défaut 0")
    void defauts() {
        Favori f = new Favori();
        f.setUtilisateurId(UUID.randomUUID());
        f.setTypeFavori("PAGE");
        f.setTitre("X");
        assertThat(f.getOrdre()).isEqualTo(0);
        assertThat(f.getNbVisites()).isEqualTo(0);
        assertThat(f.getEstPlusUtilise()).isFalse();
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        UUID userId = UUID.randomUUID();
        Favori a = new Favori();
        a.setId(id);
        a.setUtilisateurId(userId);
        a.setTypeFavori("PAGE");
        a.setTitre("T");
        Favori b = new Favori();
        b.setId(id);
        b.setUtilisateurId(userId);
        b.setTypeFavori("PAGE");
        b.setTitre("T");
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        Favori f = new Favori();
        f.setUtilisateurId(UUID.randomUUID());
        f.setTypeFavori("PAGE");
        f.setTitre("X");
        assertThat(f.toString()).isNotNull().isNotEmpty();
    }
}
