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

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

    @Test
    void testValid() {
        InvoiceStatusValidtor validator = new InvoiceStatusValidtor();
        assertTrue(validator.isValid(InvoiceStatusEnum.INVOICABLE.getCode(), constraintValidatorContext));
        assertTrue(validator.isValid(InvoiceStatusEnum.PENDINGINVOICING.getCode(), constraintValidatorContext));
        assertTrue(validator.isValid(InvoiceStatusEnum.INVOICINGSUCCESSFUL.getCode(), constraintValidatorContext));
        assertTrue(validator.isValid(InvoiceStatusEnum.INVOICINGFAILED.getCode(), constraintValidatorContext));
        assertTrue(validator.isValid(null, constraintValidatorContext));
        assertFalse(validator.isValid(4, constraintValidatorContext));
    }
}
