package com.cf.imes.module.system.validation.pay;

import com.cf.imes.framework.common.enums.StatisticsUnit;
import com.cf.imes.framework.test.core.ut.BaseMockitoUnitTest;
import jakarta.validation.ConstraintValidatorContext;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * 资金统计时间单位校验器单元测试
 *
 * @author Gqr
 * @since 2025/12/9 14:37
 */
public class FundsStatisticsUnitInEnumValidatorTest extends BaseMockitoUnitTest {
    @Mock
    private ConstraintValidatorContext constraintValidatorContext;

    @Test
    void testValid() {
        FundsStatisticsUnitInEnumValidator validator = new FundsStatisticsUnitInEnumValidator();
        assertTrue(validator.isValid(StatisticsUnit.QUARTER.getValue(), constraintValidatorContext));
        assertTrue(validator.isValid(StatisticsUnit.MONTH.getValue(), constraintValidatorContext));
        assertTrue(validator.isValid(StatisticsUnit.WEEK.getValue(), constraintValidatorContext));
        assertTrue(validator.isValid(StatisticsUnit.DAY.getValue(), constraintValidatorContext));
        assertTrue(validator.isValid(null, constraintValidatorContext));
        assertFalse(validator.isValid(4, constraintValidatorContext));
    }
}
