package projetMusee.backend;

import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;

import projetMusee.backend.enums.Granularite;

/**
 * Classe de test pour MuseumFilter.
 */
public class MuseumFilterTest {

    private List<Museum> museumList;

    @Before
    public void setUp() {
        museumList = Arrays.asList(
            new Museum("1", "Louvre", "Rue de Rivoli", "", "75001", "Paris", "Île-de-France", "75",
                "https://www.louvre.fr", "01 40 20 50 50", "Art",
                Arrays.asList("Peinture", "Sculpture"), "Musée ouvert en 1793", "Collection unique",
                "Histoire et art", "Léonard de Vinci", "Napoléon Bonaparte", "Très touristique",
                "Classé monument historique", "Patrimoine mondial", "REF123",
                1793, "2024-01-01", new Coordinates(48.8606, 2.3376)),

            new Museum("2", "Musée d'Orsay", "1 Rue de la Légion d'Honneur", "", "75007", "Paris", "Île-de-France", "75",
                "https://www.musee-orsay.fr", "01 40 49 48 14", "Art",
                Arrays.asList("Impressionnisme", "Sculpture"), "Ancienne gare transformée", "Beaux-Arts",
                "Histoire et art", "Claude Monet", "Émile Zola", "Architecture unique",
                "Classé monument historique", "Patrimoine mondial", "REF456",
                1986, "2024-01-01", new Coordinates(48.8599, 2.3266)),

            new Museum("3", "Musée des Confluences", "86 Quai Perrache", "", "69002", "Lyon", "Auvergne-Rhône-Alpes", "69",
                "https://www.museedesconfluences.fr", "04 28 38 12 12", "Science",
                Arrays.asList("Histoire", "Nature"), "Musée d'histoire naturelle", "Architecture moderne",
                "Science et découverte", "Jean Nouvel", "Albert Einstein", "Exploration scientifique",
                "Aucune", "Aucune", "REF789",
                2014, "2024-01-01", new Coordinates(45.7339, 4.8175))
        );
    }

    @Test
    public void testFilterByVille() {
        List<Museum> result = MuseumFilter.filterByVille(museumList, "Paris");
        assertEquals(2, result.size());
        assertTrue(result.stream().allMatch(m -> m.getCity().equals("Paris")));
    }

    @Test
    public void testFilterByRegion() {
        List<Museum> result = MuseumFilter.filterByRegions(museumList, "Île-de-France");
        assertEquals(2, result.size());
        assertTrue(result.stream().allMatch(m -> m.getRegion().equals("Île-de-France")));
    }

    @Test
    public void testFilterByDepartement() {
        List<Museum> result = MuseumFilter.filterByDepartement(museumList, "75");
        assertEquals(2, result.size());
        assertTrue(result.stream().allMatch(m -> m.getDepartment().equals("75")));
    }

    @Test
    public void testFilterByCreationYear() {
        List<Museum> result = MuseumFilter.filterByCreationYear(museumList, "2014");
        assertEquals(1, result.size());
        assertEquals(2014, result.get(0).getCreationYear());
    }

    @Test
    public void testFilterByTheme() {
        List<Museum> result = MuseumFilter.filterByTheme(museumList, "Peinture");
        assertEquals(1, result.size());
        assertTrue(result.get(0).getThematicDomain().contains("Peinture"));
    }
/* 
    @Test
    public void testFilterByGranularity_Ville() {
        List<Museum> result = MuseumFilter.filterByGranularity(museumList, "ville", "Lyon");
        assertEquals(1, result.size());
        assertEquals("Lyon", result.get(0).getCity());
    }
*/
    @Test
    public void testFilterByGranularity_Region() {
        List<Museum> result = MuseumFilter.filterByGranularity(museumList, Granularite.REGION, "Auvergne-Rhône-Alpes");
        assertEquals(1, result.size());
        assertEquals("Auvergne-Rhône-Alpes", result.get(0).getRegion());
    }
}
