package dev.sonpx.loyalty.agent.domain;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AgentEventTest {

    private final ObjectMapper objectMapper = new ObjectMapper();

    @Test
    void testTokenEventSerialization() throws Exception {
        AgentEvent event = AgentEvent.token("msg-123", "Hello");
        String json = objectMapper.writeValueAsString(event);
        
        assertTrue(json.contains("\"type\":\"TOKEN\""));
        assertTrue(json.contains("\"messageId\":\"msg-123\""));
        assertTrue(json.contains("\"content\":\"Hello\""));
        assertFalse(json.contains("\"tool\""));
        assertFalse(json.contains("\"status\""));
    }

    @Test
    void testToolStatusEventSerialization() throws Exception {
        AgentEvent event = AgentEvent.toolStatus("msg-123", "searchTool", "running");
        String json = objectMapper.writeValueAsString(event);
        
        assertTrue(json.contains("\"type\":\"TOOL_STATUS\""));
        assertTrue(json.contains("\"messageId\":\"msg-123\""));
        assertTrue(json.contains("\"tool\":\"searchTool\""));
        assertTrue(json.contains("\"status\":\"running\""));
        assertFalse(json.contains("\"content\""));
    }

    @Test
    void testDoneEventSerialization() throws Exception {
        AgentEvent event = AgentEvent.done("msg-123");
        String json = objectMapper.writeValueAsString(event);
        
        assertTrue(json.contains("\"type\":\"DONE\""));
        assertTrue(json.contains("\"messageId\":\"msg-123\""));
        assertFalse(json.contains("\"content\""));
    }
}
