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

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

import dev.sonpx.loyalty.agent.domain.ChatRequest;
import org.junit.jupiter.api.Test;

class ConversationKeyResolverTest {

    private final ConversationKeyResolver resolver = new ConversationKeyResolver();

    @Test
    void usesConversationIdWhenPresent() {
        ChatRequest request = new ChatRequest("conversation-1", "message-1", "hello");

        assertEquals("conversation-1", resolver.resolve(request, "connection-1"));
    }

    @Test
    void throwsExceptionWhenConversationIdMissing() {
        ChatRequest request = new ChatRequest(" ", "message-1", "hello");

        assertThrows(IllegalArgumentException.class, () -> resolver.resolve(request, "connection-1"));
    }
}
