package dev.lions.unionflow.server.repository;

import dev.lions.unionflow.server.entity.PieceJointe;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.TestTransaction;
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
class PieceJointeRepositoryTest {

    @Inject
    PieceJointeRepository pieceJointeRepository;

    @Test
    @TestTransaction
    @DisplayName("findById retourne null pour UUID inexistant")
    void findById_inexistant_returnsNull() {
        assertThat(pieceJointeRepository.findById(UUID.randomUUID())).isNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findPieceJointeById retourne empty pour UUID inexistant")
    void findPieceJointeById_inexistant_returnsEmpty() {
        Optional<PieceJointe> opt = pieceJointeRepository.findPieceJointeById(UUID.randomUUID());
        assertThat(opt).isEmpty();
    }

    @Test
    @TestTransaction
    @DisplayName("listAll retourne une liste")
    void listAll_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.listAll();
        assertThat(list).isNotNull();
    }

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

    @Test
    @TestTransaction
    @DisplayName("findByDocumentId retourne une liste")
    void findByDocumentId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByDocumentId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findByOrganisationId retourne une liste")
    void findByOrganisationId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByOrganisationId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findByMembreId retourne une liste")
    void findByMembreId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByMembreId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findByCotisationId retourne une liste")
    void findByCotisationId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByCotisationId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findByAdhesionId retourne une liste")
    void findByAdhesionId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByAdhesionId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findByDemandeAideId retourne une liste")
    void findByDemandeAideId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByDemandeAideId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }

    @Test
    @TestTransaction
    @DisplayName("findByTransactionWaveId retourne une liste")
    void findByTransactionWaveId_returnsList() {
        List<PieceJointe> list = pieceJointeRepository.findByTransactionWaveId(UUID.randomUUID());
        assertThat(list).isNotNull();
    }
}
