package com.ruoyi.web.modules.trading.support;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.trading.domain.BizSupplier;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("SupplierValidation 分配账号")
class SupplierValidationAssignAccountTest
{
    @Test
    @DisplayName("未分配可通过")
    void notAssigned()
    {
        BizSupplier row = new BizSupplier();
        row.setAccountAssigned(TradePartnerAccountRules.ACCOUNT_ASSIGNED_NO);
        assertDoesNotThrow(() -> SupplierValidation.validateForAssignAccount(row));
    }

    @Test
    @DisplayName("已分配拒绝")
    void alreadyAssigned()
    {
        BizSupplier row = new BizSupplier();
        row.setAccountAssigned(TradePartnerAccountRules.ACCOUNT_ASSIGNED_YES);
        assertThrows(ServiceException.class, () -> SupplierValidation.validateForAssignAccount(row));
    }
}
