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

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
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.architecture.domain.BizBreedingStandard;
import com.ruoyi.web.modules.innovation.domain.BizTechProjectGuide;
import com.ruoyi.web.modules.prosperity.domain.BizCommonProsperityProject;

@DisplayName("FarmingNewsDetailSupport")
class FarmingNewsDetailSupportTest
{
    @Test
    @DisplayName("养殖标准已发布且 type 匹配可见")
    void breedingVisible()
    {
        BizBreedingStandard row = new BizBreedingStandard();
        row.setPublishStatus(FarmingNewsRules.PUBLISH_STATUS_PUBLISHED);
        row.setStandardType("001001");
        assertDoesNotThrow(() -> FarmingNewsDetailSupport.assertVisibleBreeding(row, "001001"));
    }

    @Test
    @DisplayName("养殖标准未发布不可见")
    void breedingNotPublished()
    {
        BizBreedingStandard row = new BizBreedingStandard();
        row.setPublishStatus(0);
        row.setStandardType("001001");
        ServiceException ex = assertThrows(ServiceException.class,
                () -> FarmingNewsDetailSupport.assertVisibleBreeding(row, "001001"));
        assertEquals(FarmingNewsRules.NOT_FOUND_MSG, ex.getMessage());
    }

    @Test
    @DisplayName("科技项目 type 不匹配不可见")
    void techTypeMismatch()
    {
        BizTechProjectGuide row = new BizTechProjectGuide();
        row.setPublishStatus(FarmingNewsRules.PUBLISH_STATUS_PUBLISHED);
        row.setProjectType("002001");
        assertThrows(ServiceException.class, () -> FarmingNewsDetailSupport.assertVisibleTech(row, "002002"));
    }

    @Test
    @DisplayName("共富项目已发布可见")
    void prosperityVisible()
    {
        BizCommonProsperityProject row = new BizCommonProsperityProject();
        row.setPublishStatus(FarmingNewsRules.PUBLISH_STATUS_PUBLISHED);
        assertDoesNotThrow(() -> FarmingNewsDetailSupport.assertVisibleProsperity(row));
    }
}
