package com.ruoyi.ccdi.project.mapper;

import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import org.junit.jupiter.api.Test;

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

class CcdiProjectExtendedPurchaseSupplierContractTest {

    @Test
    void shouldExposeExtendedPurchaseSupplierDetailQuery() throws Exception {
        Class<?> mapperClass = Class.forName("com.ruoyi.ccdi.project.mapper.CcdiProjectSpecialCheckMapper");

        Method method = mapperClass.getMethod("selectExtendedPurchaseSuppliers", Long.class, String.class);
        assertEquals(List.class, method.getReturnType());

        String xml = Files.readString(Path.of("src/main/resources/mapper/ccdi/project/CcdiProjectSpecialCheckMapper.xml"));
        assertTrue(xml.contains("select id=\"selectExtendedPurchaseSuppliers\""));
        assertTrue(xml.contains("ccdi_purchase_transaction_supplier"));
        assertTrue(xml.contains("is_bid_winner"));
        assertTrue(xml.contains("sort_order"));
    }
}
