package com.livingworld.commands;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.List;

import org.junit.jupiter.api.Test;

import com.livingworld.regions.Region;
import com.livingworld.regions.RegionCoordinate;
import com.livingworld.regions.RegionFactory;

class RegionInfoFormatterTest {

    @Test
    void includesIdentityLifecycleMetricsFlagsAndSortedModuleIds() {
        Region region = new RegionFactory().createNewRegion(
                new RegionCoordinate("minecraft:overworld", -1, 2), 0);
        region.getMetrics().setPollutionScore(75);
        region.getFlags().setHasHighPollution(true);
        region.getModuleData().put("water", "data");
        region.getModuleData().put("soil", "data");

        List<String> lines = RegionInfoFormatter.format(region);

        assertEquals(5, lines.size());
        assertTrue(lines.get(0).contains("minecraft:overworld:-1:2"));
        assertTrue(lines.get(1).contains("ACTIVE"));
        assertTrue(lines.get(2).contains("pollution=75.0"));
        assertTrue(lines.get(3).contains("highPollution=true"));
        assertEquals("Module data: soil, water", lines.get(4));
    }

    @Test
    void validatesRegion() {
        assertThrows(IllegalArgumentException.class, () -> RegionInfoFormatter.format(null));
    }
}
