| | |
| | | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| | | import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; |
| | | import cn.iocoder.yudao.module.crm.controller.admin.customer.CrmCustomerController; |
| | | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| | |
| | | })); |
| | | var config = CrmCustomerPoolConfigService.class.cast(Proxy.newProxyInstance(getClass().getClassLoader(), |
| | | new Class<?>[]{CrmCustomerPoolConfigService.class}, (proxy, method, args) -> null)); |
| | | // 客户列表拼接会顺带统计「已签订合同」,这里桩掉,返回空 Map 表示本用例的客户没有合同 |
| | | var contracts = CrmContractService.class.cast(Proxy.newProxyInstance(getClass().getClassLoader(), |
| | | new Class<?>[]{CrmContractService.class}, (proxy, method, args) -> |
| | | switch (method.getName()) { |
| | | case "getContractCountMapByCustomerIds", "getContractPriceMapByCustomerIds" -> Map.of(); |
| | | default -> java.lang.reflect.InvocationHandler.invokeDefault(proxy, method, args); |
| | | })); |
| | | ReflectionTestUtils.setField(controller, "adminUserApi", users); |
| | | ReflectionTestUtils.setField(controller, "deptApi", departments); |
| | | ReflectionTestUtils.setField(controller, "customerPoolConfigService", config); |
| | | ReflectionTestUtils.setField(controller, "contractService", contracts); |
| | | var customer = controller.buildCustomerDetailList(List.of(new CrmCustomerDO().setId(1L) |
| | | .setOwnerUserId(10L).setAutoPoolEnabled(true))).getFirst(); |
| | | assertEquals(10L, customer.getOwnerUserId()); |