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

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.order.constant.OrderConstants;
import com.ruoyi.web.modules.order.domain.BizOrder;

class OrderSupportTest
{
    @Test
    void assertOrderBelongsToShop_passesWhenMatch()
    {
        BizOrder order = new BizOrder();
        order.setShopId(101L);
        assertEquals(order, OrderSupport.assertOrderBelongsToShop(order, 101L));
    }

    @Test
    void assertShipTab_acceptsVisibleStatuses()
    {
        OrderSupport.assertShipTab(OrderConstants.STATUS_PENDING_SHIP);
        OrderSupport.assertShipTab(OrderConstants.STATUS_SHIPPED);
        OrderSupport.assertShipTab(OrderConstants.STATUS_COMPLETED);
    }

    @Test
    void assertShipTab_rejectsInvalidStatus()
    {
        ServiceException ex = assertThrows(ServiceException.class, () -> OrderSupport.assertShipTab("0"));
        assertEquals(OrderConstants.MSG_INVALID_SHIP_TAB, ex.getMessage());
    }

    @Test
    void assertShipModuleVisible_rejectsClosed()
    {
        BizOrder order = new BizOrder();
        order.setOrderStatus(OrderConstants.STATUS_CLOSED);

        ServiceException ex = assertThrows(ServiceException.class, () -> OrderSupport.assertShipModuleVisible(order));
        assertEquals(OrderConstants.MSG_NOT_FOUND, ex.getMessage());
    }
}
