package com.easyagents.store.milvus;

import org.junit.Assert;
import org.junit.Test;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;

/**
 * {@link MilvusPrimaryKeySupport} 主键归一化测试。
 */
public class MilvusPrimaryKeySupportTest {

    /**
     * 验证数值和字符串主键都按 VarChar 类型传给 Milvus。
     */
    @Test
    public void shouldNormalizeDeleteIdsAsStrings() {
        List<Object> ids = MilvusPrimaryKeySupport.normalize(Arrays.asList(
            new BigInteger("105257799143000107"),
            42L,
            "faq-1"
        ));

        Assert.assertEquals(
            Arrays.asList("105257799143000107", "42", "faq-1"),
            ids
        );
        for (Object id : ids) {
            Assert.assertTrue(id instanceof String);
        }
    }

    /**
     * 验证空主键会被明确拒绝，避免生成无效删除表达式。
     */
    @Test(expected = NullPointerException.class)
    public void shouldRejectNullDeleteId() {
        MilvusPrimaryKeySupport.normalize(Arrays.asList("1", null));
    }
}
