package com.ruoyi.web.modules.news.mapper;

import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.StreamUtils;

@DisplayName("LivestockResourceMapper XML")
class LivestockResourceMapperXmlTest
{
    @Test
    @DisplayName("列表 SQL 查询视图并按 type、title 筛选")
    void listSql() throws Exception
    {
        String xml = StreamUtils.copyToString(
                new ClassPathResource("mapper/news/LivestockResourceMapper.xml").getInputStream(),
                StandardCharsets.UTF_8);
        assertTrue(xml.contains("v_livestock_resource"));
        assertTrue(xml.contains("source_type"));
        assertTrue(xml.contains("type = #{type}"));
        assertTrue(xml.contains("title like concat"));
        assertTrue(xml.contains("order by publish_time desc"));
    }
}
