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.BizDistributor;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

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

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