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

import com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum;
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/10 14:10
 */
class OperateLogTypeValidatorTest extends BaseMockitoUnitTest {
    @Mock
    private ConstraintValidatorContext constraintValidatorContext;

    @Test
    void testValid() {
        OperateLogTypeValidator validator = new OperateLogTypeValidator();
        assertTrue(validator.isValid(OperateTypeEnum.OTHER.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(OperateTypeEnum.CREATE.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(OperateTypeEnum.DELETE.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(OperateTypeEnum.UPDATE.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(OperateTypeEnum.GET.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(OperateTypeEnum.EXPORT.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(OperateTypeEnum.IMPORT.getType(), constraintValidatorContext));
        assertTrue(validator.isValid(null, constraintValidatorContext));
        assertFalse(validator.isValid(7, constraintValidatorContext));
    }
}
