package dev.lions.unionflow.server.repository;

import dev.lions.unionflow.server.entity.ContactPolicy;
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.Optional;
import java.util.UUID;

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

@QuarkusTest
@DisplayName("ContactPolicyRepository")
class ContactPolicyRepositoryTest {

    @Inject
    ContactPolicyRepository contactPolicyRepository;

    @Test
    @TestTransaction
    @DisplayName("findByOrganisationId retourne empty pour organisation inexistante")
    void findByOrganisationId_inexistant_returnsEmpty() {
        Optional<ContactPolicy> opt = contactPolicyRepository.findByOrganisationId(UUID.randomUUID());
        assertThat(opt).isEmpty();
    }

    @Test
    @TestTransaction
    @DisplayName("listAll retourne liste non nulle")
    void listAll_returnsNonNull() {
        assertThat(contactPolicyRepository.listAll()).isNotNull();
    }

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