package com.easyagents.core.message;

import com.easyagents.core.util.LocalTokenCounter;
import org.junit.Assert;
import org.junit.Test;

/**
 * AI 消息文本语义测试。
 */
public class AiMessageTest {

    /**
     * 验证仅设置当前内容时，完整文本接口仍能返回模型回复。
     */
    @Test
    public void currentContentShouldBeAvailableAsFullText() {
        AiMessage message = new AiMessage();
        message.setContent("2026");

        Assert.assertEquals("2026", message.getContent());
        Assert.assertEquals("2026", message.getFullContent());
        Assert.assertEquals("2026", message.getTextContent());
        Assert.assertTrue(LocalTokenCounter.countCompletionTokens(message)
                > LocalTokenCounter.countCompletionTokens(new AiMessage()));
    }

    /**
     * 验证流式消息保留增量内容，同时完整文本接口返回聚合内容。
     */
    @Test
    public void aggregatedContentShouldNotReplaceStreamingDelta() {
        AiMessage message = new AiMessage();
        message.setContent("26");
        message.setFullContent("2026");

        Assert.assertEquals("26", message.getContent());
        Assert.assertEquals("2026", message.getFullContent());
        Assert.assertEquals("2026", message.getTextContent());
    }

    /**
     * 验证仅设置当前推理内容时，完整推理接口能够正确回退。
     */
    @Test
    public void reasoningContentShouldBeAvailableAsFullReasoningText() {
        AiMessage message = new AiMessage();
        message.setReasoningContent("识别图片中的数字");

        Assert.assertEquals("识别图片中的数字", message.getFullReasoningContent());
    }
}
