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

import com.cf.imes.framework.test.core.ut.BaseMockitoUnitTest;
import com.cf.imes.module.system.enums.common.SexEnum;
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/10 14:23
 */
class SexValidatorTest extends BaseMockitoUnitTest {
    @Mock
    private ConstraintValidatorContext constraintValidatorContext;

    @Test
    void testValid() {
        SexValidator validator = new SexValidator();
        assertTrue(validator.isValid(SexEnum.MALE.getSex(), constraintValidatorContext));
        assertTrue(validator.isValid(SexEnum.FEMALE.getSex(), constraintValidatorContext));
        assertTrue(validator.isValid(SexEnum.UNKNOWN.getSex(), constraintValidatorContext));
        assertTrue(validator.isValid(null, constraintValidatorContext));
        assertFalse(validator.isValid(4, constraintValidatorContext));
    }
}