package dev.sonpx.loyalty.agent.core.workflow;

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

import dev.sonpx.loyalty.agent.core.classifier.Intent;
import java.util.Map;
import org.junit.jupiter.api.Test;

class WorkflowDataExtractorTest {

    private final WorkflowDataExtractor extractor = new WorkflowDataExtractor();

    @Test
    void extractsRuleFieldsFromNaturalLanguage() {
        WorkflowState state = new WorkflowState(Intent.RULE_CREATE);

        Map<String, Object> data = extractor.extract(state,
                "Tên rule: Birthday Bonus\nCampaign ID: CMP_BIRTHDAY\nLoại AWD\nHiệu lực 01/08/2026 -> 31/08/2026");

        assertEquals("Birthday Bonus", data.get("Tên rule"));
        assertEquals("CMP_BIRTHDAY", data.get("Campaign ID"));
        assertEquals("AWD", data.get("Loại rule"));
        assertEquals("01/08/2026 -> 31/08/2026", data.get("Thời gian hiệu lực"));
    }

    @Test
    void treatsShortAnswersAsIncompleteForBasicInfo() {
        WorkflowState state = new WorkflowState(Intent.CAMPAIGN_CREATE);

        assertTrue(!extractor.hasEnoughForNextPhase(state, "ABC"));
    }
}
