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("SuggestionVote")
class SuggestionVoteTest {

    @Test
    @DisplayName("getters/setters")
    void gettersSetters() {
        UUID suggestionId = UUID.randomUUID();
        UUID userId = UUID.randomUUID();
        LocalDateTime dateVote = LocalDateTime.now();
        SuggestionVote v = new SuggestionVote();
        v.setSuggestionId(suggestionId);
        v.setUtilisateurId(userId);
        v.setDateVote(dateVote);

        assertThat(v.getSuggestionId()).isEqualTo(suggestionId);
        assertThat(v.getUtilisateurId()).isEqualTo(userId);
        assertThat(v.getDateVote()).isEqualTo(dateVote);
    }

    @Test
    @DisplayName("equals et hashCode")
    void equalsHashCode() {
        UUID id = UUID.randomUUID();
        UUID sId = UUID.randomUUID();
        UUID uId = UUID.randomUUID();
        LocalDateTime dt = LocalDateTime.now();
        SuggestionVote a = new SuggestionVote();
        a.setId(id);
        a.setSuggestionId(sId);
        a.setUtilisateurId(uId);
        a.setDateVote(dt);
        SuggestionVote b = new SuggestionVote();
        b.setId(id);
        b.setSuggestionId(sId);
        b.setUtilisateurId(uId);
        b.setDateVote(dt);
        assertThat(a).isEqualTo(b);
        assertThat(a.hashCode()).isEqualTo(b.hashCode());
    }

    @Test
    @DisplayName("toString non null")
    void toString_nonNull() {
        SuggestionVote v = new SuggestionVote();
        v.setSuggestionId(UUID.randomUUID());
        v.setUtilisateurId(UUID.randomUUID());
        v.setDateVote(LocalDateTime.now());
        assertThat(v.toString()).isNotNull().isNotEmpty();
    }
}
