package dev.lions.unionflow.server.repository;

import dev.lions.unionflow.server.entity.MemberBlock;
import io.quarkus.test.TestTransaction;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

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

@QuarkusTest
@DisplayName("MemberBlockRepository")
class MemberBlockRepositoryTest {

    @Inject
    MemberBlockRepository memberBlockRepository;

    @Test
    @TestTransaction
    @DisplayName("estBloque retourne false si aucun blocage")
    void estBloque_returns_false() {
        boolean result = memberBlockRepository.estBloque(
            UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID());
        assertThat(result).isFalse();
    }

    @Test
    @TestTransaction
    @DisplayName("findBlocage retourne empty si aucun blocage")
    void findBlocage_returnsEmpty() {
        Optional<MemberBlock> opt = memberBlockRepository.findBlocage(
            UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID());
        assertThat(opt).isEmpty();
    }

    @Test
    @TestTransaction
    @DisplayName("findByBloqueur retourne liste vide pour membre inexistant")
    void findByBloqueur_returnsEmpty() {
        List<MemberBlock> list = memberBlockRepository.findByBloqueur(UUID.randomUUID());
        assertThat(list).isNotNull().isEmpty();
    }

    @Test
    @TestTransaction
    @DisplayName("findByBloqueurEtOrganisation retourne liste vide")
    void findByBloqueurEtOrganisation_returnsEmpty() {
        List<MemberBlock> list = memberBlockRepository.findByBloqueurEtOrganisation(
            UUID.randomUUID(), UUID.randomUUID());
        assertThat(list).isNotNull().isEmpty();
    }

    @Test
    @TestTransaction
    @DisplayName("count retourne >= 0")
    void count_returnsNonNegative() {
        assertThat(memberBlockRepository.count()).isGreaterThanOrEqualTo(0);
    }
}
