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

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
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;

@DisplayName("LivestockResourceTypeValidator")
class LivestockResourceTypeValidatorTest
{
    private final LivestockResourceTypeValidator validator = new LivestockResourceTypeValidator();

    @Test
    @DisplayName("视图内类型编码通过")
    void allowedType()
    {
        assertDoesNotThrow(() -> validator.assertAllowed(LivestockResourceRules.TYPE_VIDEO));
    }

    @Test
    @DisplayName("空 type 拒绝")
    void emptyType()
    {
        assertThrows(ServiceException.class, () -> validator.assertAllowed(null));
    }

    @Test
    @DisplayName("非视图类型拒绝")
    void invalidType()
    {
        assertThrows(ServiceException.class, () -> validator.assertAllowed("004005"));
    }
}
