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("Ticket")
class TicketTest {

    @Test
    @DisplayName("getters/setters")
    void gettersSetters() {
        Ticket t = new Ticket();
        t.setNumeroTicket("TKT-001");
        t.setUtilisateurId(UUID.randomUUID());
        t.setSujet("Problème");
        t.setDescription("Description");
        t.setCategorie("TECHNIQUE");
        t.setPriorite("HAUTE");
        t.setStatut("OUVERT");
        t.setNbMessages(2);
        t.setDateResolution(LocalDateTime.now());

        assertThat(t.getNumeroTicket()).isEqualTo("TKT-001");
        assertThat(t.getSujet()).isEqualTo("Problème");
        assertThat(t.getStatut()).isEqualTo("OUVERT");
        assertThat(t.getNbMessages()).isEqualTo(2);
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        UUID userId = UUID.randomUUID();
        Ticket a = new Ticket();
        a.setId(id);
        a.setNumeroTicket("N1");
        a.setUtilisateurId(userId);
        a.setSujet("S");
        Ticket b = new Ticket();
        b.setId(id);
        b.setNumeroTicket("N1");
        b.setUtilisateurId(userId);
        b.setSujet("S");
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        Ticket t = new Ticket();
        t.setNumeroTicket("X");
        t.setUtilisateurId(UUID.randomUUID());
        t.setSujet("S");
        assertThat(t.toString()).isNotNull().isNotEmpty();
    }
}
