Commit 94c2ad5d1d65dfea126b817ddc971701e68d19cf
1 parent
d0caa77f
修复报错的单元测试
Showing
4 changed files
with
44 additions
and
47 deletions
pom.xml
| @@ -13,16 +13,16 @@ | @@ -13,16 +13,16 @@ | ||
| 13 | <!-- Server 主项目 --> | 13 | <!-- Server 主项目 --> |
| 14 | <module>yudao-server</module> | 14 | <module>yudao-server</module> |
| 15 | <!-- 各种 module 拓展 --> | 15 | <!-- 各种 module 拓展 --> |
| 16 | - <module>yudao-module-member</module> | ||
| 17 | <module>yudao-module-system</module> | 16 | <module>yudao-module-system</module> |
| 18 | <module>yudao-module-infra</module> | 17 | <module>yudao-module-infra</module> |
| 18 | +<!-- <module>yudao-module-member</module>--> | ||
| 19 | <!-- <module>yudao-module-bpm</module>--> | 19 | <!-- <module>yudao-module-bpm</module>--> |
| 20 | <!-- <module>yudao-module-report</module>--> | 20 | <!-- <module>yudao-module-report</module>--> |
| 21 | <!-- <module>yudao-module-mp</module>--> | 21 | <!-- <module>yudao-module-mp</module>--> |
| 22 | - <module>yudao-module-pay</module> | ||
| 23 | - <module>yudao-module-mall</module> | 22 | +<!-- <module>yudao-module-pay</module>--> |
| 23 | +<!-- <module>yudao-module-mall</module>--> | ||
| 24 | <!-- 示例项目 --> | 24 | <!-- 示例项目 --> |
| 25 | - <module>yudao-example</module> | 25 | +<!-- <module>yudao-example</module>--> |
| 26 | </modules> | 26 | </modules> |
| 27 | 27 | ||
| 28 | <name>${project.artifactId}</name> | 28 | <name>${project.artifactId}</name> |
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileConfigServiceImplTest.java
| @@ -258,12 +258,12 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest { | @@ -258,12 +258,12 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest { | ||
| 258 | Long id = fileConfig.getId(); | 258 | Long id = fileConfig.getId(); |
| 259 | // mock 获得 Client | 259 | // mock 获得 Client |
| 260 | FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); | 260 | FileClient fileClient = new LocalFileClient(id, new LocalFileClientConfig()); |
| 261 | - when(fileClientFactory.getFileClient(eq(0L))).thenReturn(fileClient); | 261 | + when(fileClientFactory.getFileClient(eq(fileConfig.getId()))).thenReturn(fileClient); |
| 262 | 262 | ||
| 263 | // 调用,并断言 | 263 | // 调用,并断言 |
| 264 | assertSame(fileClient, fileConfigService.getMasterFileClient()); | 264 | assertSame(fileClient, fileConfigService.getMasterFileClient()); |
| 265 | // 断言缓存 | 265 | // 断言缓存 |
| 266 | - verify(fileClientFactory).createOrUpdateFileClient(eq(0L), eq(fileConfig.getStorage()), | 266 | + verify(fileClientFactory).createOrUpdateFileClient(eq(fileConfig.getId()), eq(fileConfig.getStorage()), |
| 267 | eq(fileConfig.getConfig())); | 267 | eq(fileConfig.getConfig())); |
| 268 | } | 268 | } |
| 269 | 269 |
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsTemplateServiceImplTest.java
| @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | 6 | import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; |
| 8 | import cn.iocoder.yudao.framework.sms.core.client.SmsClient; | 8 | import cn.iocoder.yudao.framework.sms.core.client.SmsClient; |
| 9 | -import cn.iocoder.yudao.framework.sms.core.client.SmsClientFactory; | ||
| 10 | import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; | 9 | import cn.iocoder.yudao.framework.sms.core.client.SmsCommonResult; |
| 11 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; | 10 | import cn.iocoder.yudao.framework.sms.core.client.dto.SmsTemplateRespDTO; |
| 12 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 11 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| @@ -36,7 +35,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | @@ -36,7 +35,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 36 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; | 35 | import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; |
| 37 | import static org.junit.jupiter.api.Assertions.*; | 36 | import static org.junit.jupiter.api.Assertions.*; |
| 38 | import static org.mockito.ArgumentMatchers.eq; | 37 | import static org.mockito.ArgumentMatchers.eq; |
| 39 | -import static org.mockito.Mockito.*; | 38 | +import static org.mockito.Mockito.when; |
| 40 | 39 | ||
| 41 | @Import(SmsTemplateServiceImpl.class) | 40 | @Import(SmsTemplateServiceImpl.class) |
| 42 | public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | 41 | public class SmsTemplateServiceImplTest extends BaseDbUnitTest { |
| @@ -50,8 +49,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | @@ -50,8 +49,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | ||
| 50 | @MockBean | 49 | @MockBean |
| 51 | private SmsChannelService smsChannelService; | 50 | private SmsChannelService smsChannelService; |
| 52 | @MockBean | 51 | @MockBean |
| 53 | - private SmsClientFactory smsClientFactory; | ||
| 54 | - @MockBean | ||
| 55 | private SmsClient smsClient; | 52 | private SmsClient smsClient; |
| 56 | 53 | ||
| 57 | @Test | 54 | @Test |
| @@ -82,7 +79,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | @@ -82,7 +79,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | ||
| 82 | }); | 79 | }); |
| 83 | when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); | 80 | when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); |
| 84 | // mock 获得 API 短信模板成功 | 81 | // mock 获得 API 短信模板成功 |
| 85 | - when(smsClientFactory.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); | 82 | + when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); |
| 86 | when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn(randomPojo(SmsCommonResult.class, SmsTemplateRespDTO.class, | 83 | when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn(randomPojo(SmsCommonResult.class, SmsTemplateRespDTO.class, |
| 87 | o -> o.setCode(GlobalErrorCodeConstants.SUCCESS.getCode()))); | 84 | o -> o.setCode(GlobalErrorCodeConstants.SUCCESS.getCode()))); |
| 88 | 85 | ||
| @@ -117,7 +114,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | @@ -117,7 +114,7 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest { | ||
| 117 | }); | 114 | }); |
| 118 | when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); | 115 | when(smsChannelService.getSmsChannel(eq(channelDO.getId()))).thenReturn(channelDO); |
| 119 | // mock 获得 API 短信模板成功 | 116 | // mock 获得 API 短信模板成功 |
| 120 | - when(smsClientFactory.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); | 117 | + when(smsChannelService.getSmsClient(eq(reqVO.getChannelId()))).thenReturn(smsClient); |
| 121 | when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn(randomPojo(SmsCommonResult.class, SmsTemplateRespDTO.class, | 118 | when(smsClient.getSmsTemplate(eq(reqVO.getApiTemplateId()))).thenReturn(randomPojo(SmsCommonResult.class, SmsTemplateRespDTO.class, |
| 122 | o -> o.setCode(GlobalErrorCodeConstants.SUCCESS.getCode()))); | 119 | o -> o.setCode(GlobalErrorCodeConstants.SUCCESS.getCode()))); |
| 123 | 120 |
yudao-server/pom.xml
| @@ -37,11 +37,11 @@ | @@ -37,11 +37,11 @@ | ||
| 37 | </dependency> | 37 | </dependency> |
| 38 | 38 | ||
| 39 | <!-- 会员中心。默认注释,保证编译速度 --> | 39 | <!-- 会员中心。默认注释,保证编译速度 --> |
| 40 | - <dependency> | ||
| 41 | - <groupId>cn.iocoder.boot</groupId> | ||
| 42 | - <artifactId>yudao-module-member-biz</artifactId> | ||
| 43 | - <version>${revision}</version> | ||
| 44 | - </dependency> | 40 | +<!-- <dependency>--> |
| 41 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 42 | +<!-- <artifactId>yudao-module-member-biz</artifactId>--> | ||
| 43 | +<!-- <version>${revision}</version>--> | ||
| 44 | +<!-- </dependency>--> | ||
| 45 | 45 | ||
| 46 | <!-- 数据报表。默认注释,保证编译速度 --> | 46 | <!-- 数据报表。默认注释,保证编译速度 --> |
| 47 | <!-- <dependency>--> | 47 | <!-- <dependency>--> |
| @@ -56,40 +56,40 @@ | @@ -56,40 +56,40 @@ | ||
| 56 | <!-- <version>${revision}</version>--> | 56 | <!-- <version>${revision}</version>--> |
| 57 | <!-- </dependency>--> | 57 | <!-- </dependency>--> |
| 58 | <!-- 支付服务。默认注释,保证编译速度 --> | 58 | <!-- 支付服务。默认注释,保证编译速度 --> |
| 59 | - <dependency> | ||
| 60 | - <groupId>cn.iocoder.boot</groupId> | ||
| 61 | - <artifactId>yudao-module-pay-biz</artifactId> | ||
| 62 | - <version>${revision}</version> | ||
| 63 | - </dependency> | 59 | +<!-- <dependency>--> |
| 60 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 61 | +<!-- <artifactId>yudao-module-pay-biz</artifactId>--> | ||
| 62 | +<!-- <version>${revision}</version>--> | ||
| 63 | +<!-- </dependency>--> | ||
| 64 | 64 | ||
| 65 | <!-- 微信公众号模块。默认注释,保证编译速度 --> | 65 | <!-- 微信公众号模块。默认注释,保证编译速度 --> |
| 66 | - <dependency> | ||
| 67 | - <groupId>cn.iocoder.boot</groupId> | ||
| 68 | - <artifactId>yudao-module-mp-biz</artifactId> | ||
| 69 | - <version>${revision}</version> | ||
| 70 | - </dependency> | 66 | +<!-- <dependency>--> |
| 67 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 68 | +<!-- <artifactId>yudao-module-mp-biz</artifactId>--> | ||
| 69 | +<!-- <version>${revision}</version>--> | ||
| 70 | +<!-- </dependency>--> | ||
| 71 | 71 | ||
| 72 | <!-- 商城相关模块。默认注释,保证编译速度--> | 72 | <!-- 商城相关模块。默认注释,保证编译速度--> |
| 73 | - <dependency> | ||
| 74 | - <groupId>cn.iocoder.boot</groupId> | ||
| 75 | - <artifactId>yudao-module-promotion-biz</artifactId> | ||
| 76 | - <version>${revision}</version> | ||
| 77 | - </dependency> | ||
| 78 | - <dependency> | ||
| 79 | - <groupId>cn.iocoder.boot</groupId> | ||
| 80 | - <artifactId>yudao-module-product-biz</artifactId> | ||
| 81 | - <version>${revision}</version> | ||
| 82 | - </dependency> | ||
| 83 | - <dependency> | ||
| 84 | - <groupId>cn.iocoder.boot</groupId> | ||
| 85 | - <artifactId>yudao-module-trade-biz</artifactId> | ||
| 86 | - <version>${revision}</version> | ||
| 87 | - </dependency> | ||
| 88 | - <dependency> | ||
| 89 | - <groupId>cn.iocoder.boot</groupId> | ||
| 90 | - <artifactId>yudao-module-statistics-biz</artifactId> | ||
| 91 | - <version>${revision}</version> | ||
| 92 | - </dependency> | 73 | +<!-- <dependency>--> |
| 74 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 75 | +<!-- <artifactId>yudao-module-promotion-biz</artifactId>--> | ||
| 76 | +<!-- <version>${revision}</version>--> | ||
| 77 | +<!-- </dependency>--> | ||
| 78 | +<!-- <dependency>--> | ||
| 79 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 80 | +<!-- <artifactId>yudao-module-product-biz</artifactId>--> | ||
| 81 | +<!-- <version>${revision}</version>--> | ||
| 82 | +<!-- </dependency>--> | ||
| 83 | +<!-- <dependency>--> | ||
| 84 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 85 | +<!-- <artifactId>yudao-module-trade-biz</artifactId>--> | ||
| 86 | +<!-- <version>${revision}</version>--> | ||
| 87 | +<!-- </dependency>--> | ||
| 88 | +<!-- <dependency>--> | ||
| 89 | +<!-- <groupId>cn.iocoder.boot</groupId>--> | ||
| 90 | +<!-- <artifactId>yudao-module-statistics-biz</artifactId>--> | ||
| 91 | +<!-- <version>${revision}</version>--> | ||
| 92 | +<!-- </dependency>--> | ||
| 93 | 93 | ||
| 94 | <!-- spring boot 配置所需依赖 --> | 94 | <!-- spring boot 配置所需依赖 --> |
| 95 | <dependency> | 95 | <dependency> |