gaoluyang
2 天以前 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
yudao-module-mes/src/test/java/cn/iocoder/yudao/module/mes/service/pro/task/schedule/MesProBatchScheduleServiceTest.java
@@ -13,7 +13,6 @@
import cn.iocoder.yudao.module.mes.dal.mysql.dv.machinery.MesDvMachineryMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.pro.task.MesProTaskMapper;
import cn.iocoder.yudao.module.mes.dal.mysql.pro.workorder.MesProWorkOrderMapper;
import cn.iocoder.yudao.module.mes.service.cal.holiday.MesCalHolidayService;
import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService;
import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService;
@@ -188,7 +187,17 @@
    }
    private static <T> T stub(Class<T> type, InvocationHandler handler) {
        return type.cast(Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, handler));
        return type.cast(Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[]{type}, (proxy, method, args) -> {
            if (method.getDeclaringClass() == Object.class) {
                return switch (method.getName()) {
                    case "toString" -> type.getSimpleName() + "Stub";
                    case "hashCode" -> System.identityHashCode(proxy);
                    case "equals" -> proxy == args[0];
                    default -> throw new AssertionError(method.getName());
                };
            }
            return handler.invoke(proxy, method, args);
        }));
    }
    static class Fixture {
@@ -233,7 +242,6 @@
                    new MesMdWorkstationDO().setId(2L).setName("工作站B").setProcessId(2L).setStatus(0))));
            set("machineryMapper", stub(MesDvMachineryMapper.class, (p,m,a) -> machines));
            set("customerApi", stub(CrmCustomerApi.class, (p,m,a) -> null));
            set("holidayService", stub(MesCalHolidayService.class, (p,m,a) -> List.of()));
            set("workOrderProcessService", stub(MesProWorkOrderProcessService.class, (p,m,a) -> processes));
            var quantities = new MesProScheduleQuantityService();
            ReflectionTestUtils.setField(quantities, "workOrderProcessService", stub(MesProWorkOrderProcessService.class, (p,m,a) -> processes));