package com.ruoyi.info.collection.mapper;

import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class CcdiCreditInfoQueryMapperXmlTest {

    @Test
    void selectCreditInfoPage_shouldAggregateByCreditObject() throws Exception {
        Path xmlPath = Path.of("src/main/resources/mapper/info/collection/CcdiCreditInfoQueryMapper.xml");
        String source = Files.readString(xmlPath, StandardCharsets.UTF_8);

        assertFalse(source.contains("FROM ccdi_base_staff"),
                "征信维护列表不应再从员工表驱动查询");
        assertFalse(source.contains("query.staffId"),
                "征信维护列表不应再接收柜员号筛选");
        assertFalse(source.contains("query.maintained"),
                "征信维护列表不应再接收是否已维护筛选");
        assertFalse(source.contains(") keys"),
                "征信维护列表不应使用 MySQL 保留字作为派生表别名");
        assertTrue(source.contains("person_id"),
                "征信维护列表必须按征信对象证件号聚合");
    }
}
