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("LivestockResourceSourceTypeValidator")
class LivestockResourceSourceTypeValidatorTest
{
    private final LivestockResourceSourceTypeValidator validator = new LivestockResourceSourceTypeValidator();

    @Test
    @DisplayName("来源 1/2 通过")
    void allowed()
    {
        assertDoesNotThrow(() -> validator.assertAllowed(LivestockResourceRules.SOURCE_MEDICAL));
        assertDoesNotThrow(() -> validator.assertAllowed(LivestockResourceRules.SOURCE_TECH));
    }

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

    @Test
    @DisplayName("非法来源拒绝")
    void invalid()
    {
        assertThrows(ServiceException.class, () -> validator.assertAllowed(3));
    }
}
