| | |
| | | |
| | | class MesProScheduleGuardTest { |
| | | 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); |
| | | })); |
| | | } |
| | | private final List<MesProTaskDO> tasks = new ArrayList<>(); |
| | | private final MesProWorkOrderDO order = new MesProWorkOrderDO().setId(1L).setType(1).setQuantity(BigDecimal.valueOf(100)); |