package kz.konturai.parser.service;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.lang.reflect.Method;

import org.junit.jupiter.api.Test;

import kz.konturai.parser.model.DetailLevel;

class MarketingAnalysisServiceDetailLevelPromptTest {

    // Keep this test free of Spring/Mockito to avoid agent-attach requirements.
    private final MarketingAnalysisService marketingAnalysisService = new MarketingAnalysisService(null, null, null,
            null, null, null);

    @Test
    void appendDetailLevelDirectives_shouldForceBullets_forKratko() throws Exception {
        Method m = MarketingAnalysisService.class.getDeclaredMethod(
                "appendDetailLevelDirectives",
                StringBuilder.class,
                DetailLevel.class,
                String.class);
        m.setAccessible(true);

        StringBuilder sb = new StringBuilder();
        m.invoke(marketingAnalysisService, sb, DetailLevel.КРАТКО, "summary");

        String out = sb.toString();
        assertTrue(out.contains("РЕЖИМ КРАТКО"));
        assertTrue(out.contains("bullet points"));
        assertTrue(out.contains("Игнорируй любые требования"));
    }

    @Test
    void buildSystemPromptForSection_shouldReturnNull_whenNotPodrobno() throws Exception {
        Method m = MarketingAnalysisService.class.getDeclaredMethod(
                "buildSystemPromptForSection",
                DetailLevel.class,
                String.class);
        m.setAccessible(true);

        Object out = m.invoke(marketingAnalysisService, DetailLevel.КРАТКО, "audience");
        assertNull(out);
    }

    @Test
    void buildSystemPromptForSection_shouldIncludeAcademicDirective_whenPodrobno() throws Exception {
        Method m = MarketingAnalysisService.class.getDeclaredMethod(
                "buildSystemPromptForSection",
                DetailLevel.class,
                String.class);
        m.setAccessible(true);

        String out = (String) m.invoke(marketingAnalysisService, DetailLevel.ПОДРОБНО, "audience");
        assertNotNull(out);
        assertTrue(out.contains("глубокий академический анализ"));
        assertTrue(out.contains("LTV"));
        assertTrue(out.contains("Porter's Five Forces"));
    }
}
