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

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.news.support.FarmingNewsRules.SourceTable;

@DisplayName("FarmingNewsRules.resolveSourceTable")
class FarmingNewsRulesTest
{
    @Test
    @DisplayName("type 路由到对应源表")
    void resolveRoutes()
    {
        assertEquals(SourceTable.BREEDING_STANDARD, FarmingNewsRules.resolveSourceTable("001001"));
        assertEquals(SourceTable.BREEDING_STANDARD, FarmingNewsRules.resolveSourceTable("001004"));
        assertEquals(SourceTable.FEEDING_STANDARD, FarmingNewsRules.resolveSourceTable("001005"));
        assertEquals(SourceTable.EQUIPMENT_WORK_STANDARD, FarmingNewsRules.resolveSourceTable("001010"));
        assertEquals(SourceTable.GROWTH_SLAUGHTER_STANDARD, FarmingNewsRules.resolveSourceTable("001012"));
        assertEquals(SourceTable.TECH_PROJECT_GUIDE, FarmingNewsRules.resolveSourceTable("002003"));
        assertEquals(SourceTable.INDUSTRY_POLICY_PUBLICITY, FarmingNewsRules.resolveSourceTable("003001"));
        assertEquals(SourceTable.SUBSIDY_PROJECT, FarmingNewsRules.resolveSourceTable("003002"));
        assertEquals(SourceTable.SUBSIDY_MATTER, FarmingNewsRules.resolveSourceTable("003003"));
        assertEquals(SourceTable.COMMON_PROSPERITY_PROJECT, FarmingNewsRules.resolveSourceTable("003004"));
    }

    @Test
    @DisplayName("未知 type 失败")
    void resolveUnknown()
    {
        assertThrows(ServiceException.class, () -> FarmingNewsRules.resolveSourceTable("001013"));
        assertThrows(ServiceException.class, () -> FarmingNewsRules.resolveSourceTable("999999"));
    }
}
