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

import com.cf.imes.framework.test.core.ut.BaseMockitoUnitTest;
import com.cf.imes.module.system.enums.pay.ProductDurationUnitEnum;
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:27
 */
public class ProductDurationUnitValidatorTest extends BaseMockitoUnitTest {
    @Mock
    private ConstraintValidatorContext constraintValidatorContext;

    @Test
    void testValid() {
        ProductDurationUnitValidator validator = new ProductDurationUnitValidator();
        assertTrue(validator.isValid(ProductDurationUnitEnum.YEAR.getCode(), constraintValidatorContext));
        assertFalse(validator.isValid(ProductDurationUnitEnum.MONTH.getCode(), constraintValidatorContext));
        assertTrue(validator.isValid(null, constraintValidatorContext));
        assertFalse(validator.isValid(2, constraintValidatorContext));
    }
}
