package com.easyagents.core.model.chat.log;

import com.easyagents.core.model.chat.ChatConfig;
import org.junit.Assert;
import org.junit.Test;

import java.util.concurrent.atomic.AtomicReference;

/**
 * 默认聊天日志记录器测试。
 */
public class DefaultChatMessageLoggerTest {

    /**
     * 验证请求日志不会输出完整图片 Base64。
     */
    @Test
    public void shouldRedactImageDataUriPayload() {
        AtomicReference<String> logged = new AtomicReference<>();
        DefaultChatMessageLogger logger = new DefaultChatMessageLogger(logged::set);
        ChatConfig config = new ChatConfig();
        config.setProvider("test");
        config.setModel("vision");

        logger.logRequest(config,
                "{\"url\":\"data:image/png;base64,AQIDBA==\",\"text\":\"ok\"}");

        Assert.assertNotNull(logged.get());
        Assert.assertTrue(logged.get().contains("data:image/png;base64,<已脱敏，编码长度=8>"));
        Assert.assertFalse(logged.get().contains("AQIDBA=="));
    }
}
