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.diagnosis.domain.BizMedicalResource;
import com.ruoyi.web.modules.diagnosis.support.MedicalResourceRules;
import com.ruoyi.web.modules.farming.domain.BizTechResource;
import com.ruoyi.web.modules.farming.support.TechResourceRules;

@DisplayName("LivestockResourceDetailSupport")
class LivestockResourceDetailSupportTest
{
    @Test
    @DisplayName("医疗已发布专家团队可见")
    void medicalVisible()
    {
        BizMedicalResource row = new BizMedicalResource();
        row.setPublishStatus(MedicalResourceRules.PUBLISH_STATUS_PUBLISHED);
        row.setResourceType(LivestockResourceRules.TYPE_EXPERT_TEAM);
        LivestockResourceDetailSupport.assertVisibleMedical(row);
    }

    @Test
    @DisplayName("医疗未发布不可见")
    void medicalNotPublished()
    {
        BizMedicalResource row = new BizMedicalResource();
        row.setPublishStatus(MedicalResourceRules.PUBLISH_STATUS_DRAFT);
        row.setResourceType(LivestockResourceRules.TYPE_EXPERT_TEAM);
        ServiceException ex = assertThrows(ServiceException.class,
                () -> LivestockResourceDetailSupport.assertVisibleMedical(row));
        assertEquals(LivestockResourceRules.NOT_FOUND_MSG, ex.getMessage());
    }

    @Test
    @DisplayName("科技已发布技术成果可见")
    void techVisible()
    {
        BizTechResource row = new BizTechResource();
        row.setPublishStatus(TechResourceRules.PUBLISH_STATUS_PUBLISHED);
        row.setResourceType(LivestockResourceRules.TYPE_ACHIEVEMENT);
        LivestockResourceDetailSupport.assertVisibleTech(row);
    }

    @Test
    @DisplayName("科技非视图类型不可见")
    void techWrongType()
    {
        BizTechResource row = new BizTechResource();
        row.setPublishStatus(TechResourceRules.PUBLISH_STATUS_PUBLISHED);
        row.setResourceType(TechResourceRules.RESOURCE_TYPE_EXPERT);
        assertThrows(ServiceException.class, () -> LivestockResourceDetailSupport.assertVisibleTech(row));
    }
}
