Commit 61672e0180083dd6fceaf1f53bc6e48474d2c216
1 parent
eb2ab3cc
多模块重构 13:迁移集成测试~
Showing
19 changed files
with
247 additions
and
79 deletions
yudao-framework/yudao-spring-boot-starter-job/pom.xml
| @@ -35,6 +35,8 @@ | @@ -35,6 +35,8 @@ | ||
| 35 | <groupId>jakarta.validation</groupId> | 35 | <groupId>jakarta.validation</groupId> |
| 36 | <artifactId>jakarta.validation-api</artifactId> | 36 | <artifactId>jakarta.validation-api</artifactId> |
| 37 | </dependency> | 37 | </dependency> |
| 38 | + | ||
| 39 | + | ||
| 38 | </dependencies> | 40 | </dependencies> |
| 39 | 41 | ||
| 40 | </project> | 42 | </project> |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java renamed to yudao-module-system/yudao-module-system-impl/src/test-integration/java/cn/iocoder/yudao/module/system/job/SchedulerManagerTest.java
| 1 | -package cn.iocoder.yudao.server.framework.quartz.core; | 1 | +package cn.iocoder.yudao.module.system.job; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | -import cn.iocoder.yudao.server.BaseDbUnitTest; | ||
| 5 | -import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob; | ||
| 6 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; | 4 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; |
| 5 | +import cn.iocoder.yudao.module.system.job.auth.UserSessionTimeoutJob; | ||
| 6 | +import cn.iocoder.yudao.module.system.test.BaseDbUnitTest; | ||
| 7 | import org.junit.jupiter.api.Test; | 7 | import org.junit.jupiter.api.Test; |
| 8 | import org.quartz.SchedulerException; | 8 | import org.quartz.SchedulerException; |
| 9 | 9 | ||
| 10 | import javax.annotation.Resource; | 10 | import javax.annotation.Resource; |
| 11 | 11 | ||
| 12 | -class SchedulerManagerTest extends BaseDbUnitTest { | 12 | +public class SchedulerManagerTest extends BaseDbUnitTest { |
| 13 | 13 | ||
| 14 | @Resource | 14 | @Resource |
| 15 | private SchedulerManager schedulerManager; | 15 | private SchedulerManager schedulerManager; |
| 16 | 16 | ||
| 17 | @Test | 17 | @Test |
| 18 | public void testAddJob() throws SchedulerException { | 18 | public void testAddJob() throws SchedulerException { |
| 19 | - String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName()); | 19 | + String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); |
| 20 | schedulerManager.addJob(1L, jobHandlerName, "test", "0/10 * * * * ? *", 0, 0); | 20 | schedulerManager.addJob(1L, jobHandlerName, "test", "0/10 * * * * ? *", 0, 0); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | @Test | 23 | @Test |
| 24 | public void testUpdateJob() throws SchedulerException { | 24 | public void testUpdateJob() throws SchedulerException { |
| 25 | - String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName()); | 25 | + String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); |
| 26 | schedulerManager.updateJob(jobHandlerName, "hahaha", "0/20 * * * * ? *", 0, 0); | 26 | schedulerManager.updateJob(jobHandlerName, "hahaha", "0/20 * * * * ? *", 0, 0); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | @Test | 29 | @Test |
| 30 | public void testDeleteJob() throws SchedulerException { | 30 | public void testDeleteJob() throws SchedulerException { |
| 31 | - String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName()); | 31 | + String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); |
| 32 | schedulerManager.deleteJob(jobHandlerName); | 32 | schedulerManager.deleteJob(jobHandlerName); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | @Test | 35 | @Test |
| 36 | public void testPauseJob() throws SchedulerException { | 36 | public void testPauseJob() throws SchedulerException { |
| 37 | - String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName()); | 37 | + String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); |
| 38 | schedulerManager.pauseJob(jobHandlerName); | 38 | schedulerManager.pauseJob(jobHandlerName); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | @Test | 41 | @Test |
| 42 | public void testResumeJob() throws SchedulerException { | 42 | public void testResumeJob() throws SchedulerException { |
| 43 | - String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName()); | 43 | + String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); |
| 44 | schedulerManager.resumeJob(jobHandlerName); | 44 | schedulerManager.resumeJob(jobHandlerName); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | @Test | 47 | @Test |
| 48 | public void testTriggerJob() throws SchedulerException { | 48 | public void testTriggerJob() throws SchedulerException { |
| 49 | - String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName()); | 49 | + String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName()); |
| 50 | schedulerManager.triggerJob(1L, jobHandlerName, "niubi!!!"); | 50 | schedulerManager.triggerJob(1L, jobHandlerName, "niubi!!!"); |
| 51 | } | 51 | } |
| 52 | 52 |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java renamed to yudao-module-system/yudao-module-system-impl/src/test-integration/java/cn/iocoder/yudao/module/system/mq/RedisStreamTest.java
| 1 | -package cn.iocoder.yudao.server.framework.redis.core.stream; | 1 | +package cn.iocoder.yudao.module.system.mq; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.thread.ThreadUtil; | 3 | import cn.hutool.core.thread.ThreadUtil; |
| 4 | -import cn.iocoder.yudao.server.BaseRedisIntegrationTest; | ||
| 5 | -import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer; | ||
| 6 | -import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; | ||
| 7 | -import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage; | ||
| 8 | -import cn.iocoder.yudao.module.system.mq.message.sms.SysSmsSendMessage; | ||
| 9 | -import cn.iocoder.yudao.framework.mq.core.util.RedisMessageUtils; | 4 | +import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate; |
| 5 | +import cn.iocoder.yudao.module.system.mq.consumer.mail.MailSendConsumer; | ||
| 6 | +import cn.iocoder.yudao.module.system.mq.consumer.sms.SmsSendConsumer; | ||
| 7 | +import cn.iocoder.yudao.module.system.mq.message.mail.MailSendMessage; | ||
| 8 | +import cn.iocoder.yudao.module.system.mq.message.sms.SmsSendMessage; | ||
| 9 | +import cn.iocoder.yudao.module.system.test.BaseRedisIntegrationTest; | ||
| 10 | import org.junit.jupiter.api.Disabled; | 10 | import org.junit.jupiter.api.Disabled; |
| 11 | import org.junit.jupiter.api.Test; | 11 | import org.junit.jupiter.api.Test; |
| 12 | import org.springframework.context.annotation.Import; | 12 | import org.springframework.context.annotation.Import; |
| 13 | import org.springframework.data.redis.core.RedisTemplate; | 13 | import org.springframework.data.redis.core.RedisTemplate; |
| 14 | -import org.springframework.data.redis.core.StringRedisTemplate; | ||
| 15 | 14 | ||
| 16 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| 17 | import java.util.concurrent.TimeUnit; | 16 | import java.util.concurrent.TimeUnit; |
| 18 | 17 | ||
| 19 | public class RedisStreamTest { | 18 | public class RedisStreamTest { |
| 20 | 19 | ||
| 21 | - @Import({SysSmsSendConsumer.class, SysMailSendConsumer.class}) | 20 | + @Import({SmsSendConsumer.class, MailSendConsumer.class}) |
| 22 | @Disabled | 21 | @Disabled |
| 23 | public static class ConsumerTest extends BaseRedisIntegrationTest { | 22 | public static class ConsumerTest extends BaseRedisIntegrationTest { |
| 24 | 23 | ||
| @@ -33,7 +32,7 @@ public class RedisStreamTest { | @@ -33,7 +32,7 @@ public class RedisStreamTest { | ||
| 33 | public static class ProducerTest extends BaseRedisIntegrationTest { | 32 | public static class ProducerTest extends BaseRedisIntegrationTest { |
| 34 | 33 | ||
| 35 | @Resource | 34 | @Resource |
| 36 | - private StringRedisTemplate stringRedisTemplate; | 35 | + private RedisMQTemplate redisMQTemplate; |
| 37 | 36 | ||
| 38 | @Resource | 37 | @Resource |
| 39 | private RedisTemplate<String, Object> redisTemplate; | 38 | private RedisTemplate<String, Object> redisTemplate; |
| @@ -42,20 +41,20 @@ public class RedisStreamTest { | @@ -42,20 +41,20 @@ public class RedisStreamTest { | ||
| 42 | public void testProducer01() { | 41 | public void testProducer01() { |
| 43 | for (int i = 0; i < 100; i++) { | 42 | for (int i = 0; i < 100; i++) { |
| 44 | // 创建消息 | 43 | // 创建消息 |
| 45 | - SysSmsSendMessage message = new SysSmsSendMessage(); | 44 | + SmsSendMessage message = new SmsSendMessage(); |
| 46 | message.setMobile("15601691300").setApiTemplateId("test:" + i); | 45 | message.setMobile("15601691300").setApiTemplateId("test:" + i); |
| 47 | // 发送消息 | 46 | // 发送消息 |
| 48 | - RedisMessageUtils.sendStreamMessage(stringRedisTemplate, message); | 47 | + redisMQTemplate.send(message); |
| 49 | } | 48 | } |
| 50 | } | 49 | } |
| 51 | 50 | ||
| 52 | @Test | 51 | @Test |
| 53 | public void testProducer02() { | 52 | public void testProducer02() { |
| 54 | // 创建消息 | 53 | // 创建消息 |
| 55 | - SysMailSendMessage message = new SysMailSendMessage(); | 54 | + MailSendMessage message = new MailSendMessage(); |
| 56 | message.setAddress("fangfang@mihayou.com").setTemplateCode("test"); | 55 | message.setAddress("fangfang@mihayou.com").setTemplateCode("test"); |
| 57 | // 发送消息 | 56 | // 发送消息 |
| 58 | - RedisMessageUtils.sendStreamMessage(stringRedisTemplate, message); | 57 | + redisMQTemplate.send(message); |
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | } | 60 | } |
yudao-module-system/yudao-module-system-impl/src/test-integration/java/cn/iocoder/yudao/module/system/service/package-info.java
0 → 100644
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java renamed to yudao-module-system/yudao-module-system-impl/src/test-integration/java/cn/iocoder/yudao/module/system/service/sms/SmsServiceIntegrationTest.java
| @@ -2,16 +2,12 @@ package cn.iocoder.yudao.module.system.service.sms; | @@ -2,16 +2,12 @@ package cn.iocoder.yudao.module.system.service.sms; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | import cn.hutool.core.thread.ThreadUtil; | 4 | import cn.hutool.core.thread.ThreadUtil; |
| 5 | -import cn.iocoder.yudao.server.BaseDbAndRedisIntegrationTest; | ||
| 6 | -import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; | ||
| 7 | -import cn.iocoder.yudao.module.system.mq.producer.sms.SysSmsProducer; | ||
| 8 | -import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl; | ||
| 9 | -import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsLogServiceImpl; | ||
| 10 | -import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsTemplateServiceImpl; | ||
| 11 | -import cn.iocoder.yudao.module.system.service.user.SysUserService; | ||
| 12 | -import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsCoreServiceImpl; | ||
| 13 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 14 | import cn.iocoder.yudao.framework.sms.config.YudaoSmsAutoConfiguration; | 6 | import cn.iocoder.yudao.framework.sms.config.YudaoSmsAutoConfiguration; |
| 7 | +import cn.iocoder.yudao.module.system.test.BaseDbAndRedisIntegrationTest; | ||
| 8 | +import cn.iocoder.yudao.module.system.mq.consumer.sms.SmsSendConsumer; | ||
| 9 | +import cn.iocoder.yudao.module.system.mq.producer.sms.SmsProducer; | ||
| 10 | +import cn.iocoder.yudao.module.system.service.user.AdminUserService; | ||
| 15 | import org.junit.jupiter.api.Test; | 11 | import org.junit.jupiter.api.Test; |
| 16 | import org.springframework.boot.test.mock.mockito.MockBean; | 12 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 17 | import org.springframework.context.annotation.Import; | 13 | import org.springframework.context.annotation.Import; |
| @@ -22,17 +18,17 @@ import java.util.concurrent.TimeUnit; | @@ -22,17 +18,17 @@ import java.util.concurrent.TimeUnit; | ||
| 22 | 18 | ||
| 23 | // TODO @芋艿:需要迁移 | 19 | // TODO @芋艿:需要迁移 |
| 24 | @Import({YudaoSmsAutoConfiguration.class, | 20 | @Import({YudaoSmsAutoConfiguration.class, |
| 25 | - SysSmsChannelServiceImpl.class, SysSmsCoreServiceImpl.class, SysSmsTemplateServiceImpl.class, SysSmsLogServiceImpl.class, | ||
| 26 | - SysSmsProducer.class, SysSmsSendConsumer.class}) | ||
| 27 | -public class SysSmsServiceIntegrationTest extends BaseDbAndRedisIntegrationTest { | 21 | + SmsChannelServiceImpl.class, SmsSendServiceImpl.class, SmsTemplateServiceImpl.class, SmsLogServiceImpl.class, |
| 22 | + SmsProducer.class, SmsSendConsumer.class}) | ||
| 23 | +public class SmsServiceIntegrationTest extends BaseDbAndRedisIntegrationTest { | ||
| 28 | 24 | ||
| 29 | @Resource | 25 | @Resource |
| 30 | - private SysSmsCoreServiceImpl smsService; | 26 | + private SmsSendServiceImpl smsService; |
| 31 | @Resource | 27 | @Resource |
| 32 | - private SysSmsChannelServiceImpl smsChannelService; | 28 | + private SmsChannelServiceImpl smsChannelService; |
| 33 | 29 | ||
| 34 | @MockBean | 30 | @MockBean |
| 35 | - private SysUserService userService; | 31 | + private AdminUserService userService; |
| 36 | 32 | ||
| 37 | @Test | 33 | @Test |
| 38 | public void testSendSingleSms_yunpianSuccess() { | 34 | public void testSendSingleSms_yunpianSuccess() { |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java renamed to yudao-module-system/yudao-module-system-impl/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseDbAndRedisIntegrationTest.java
| 1 | -package cn.iocoder.yudao.server; | 1 | +package cn.iocoder.yudao.module.system.test; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; | 3 | import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; |
| 4 | import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; | 4 | import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java renamed to yudao-module-system/yudao-module-system-impl/src/test-integration/java/cn/iocoder/yudao/module/system/test/BaseRedisIntegrationTest.java
| 1 | -package cn.iocoder.yudao.server; | 1 | +package cn.iocoder.yudao.module.system.test; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; | 3 | import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; |
| 4 | import org.redisson.spring.starter.RedissonAutoConfiguration; | 4 | import org.redisson.spring.starter.RedissonAutoConfiguration; |
yudao-server/src/test-integration/resources/application-integration-test.yaml renamed to yudao-module-system/yudao-module-system-impl/src/test-integration/resources/application-integration-test.yaml
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java renamed to yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaColumnMapperTest.java
| 1 | package cn.iocoder.yudao.module.tool.dal.mysql.codegen; | 1 | package cn.iocoder.yudao.module.tool.dal.mysql.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.server.BaseDbUnitTest; | ||
| 4 | -import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO; | 3 | +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO; |
| 4 | +import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; | ||
| 5 | import org.junit.jupiter.api.Test; | 5 | import org.junit.jupiter.api.Test; |
| 6 | 6 | ||
| 7 | import javax.annotation.Resource; | 7 | import javax.annotation.Resource; |
| @@ -9,15 +9,14 @@ import java.util.List; | @@ -9,15 +9,14 @@ import java.util.List; | ||
| 9 | 9 | ||
| 10 | import static org.junit.jupiter.api.Assertions.assertTrue; | 10 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 11 | 11 | ||
| 12 | -public class ToolInformationSchemaColumnMapperTest extends BaseDbUnitTest { | 12 | +public class SchemaColumnMapperTest extends BaseDbUnitTest { |
| 13 | 13 | ||
| 14 | @Resource | 14 | @Resource |
| 15 | - private ToolSchemaColumnMapper toolInformationSchemaColumnMapper; | 15 | + private SchemaColumnMapper schemaColumnMapper; |
| 16 | 16 | ||
| 17 | @Test | 17 | @Test |
| 18 | public void testSelectListByTableName() { | 18 | public void testSelectListByTableName() { |
| 19 | - List<ToolSchemaColumnDO> columns = toolInformationSchemaColumnMapper | ||
| 20 | - .selectListByTableName("", "inf_config"); | 19 | + List<SchemaColumnDO> columns = schemaColumnMapper.selectListByTableName("", "inf_config"); |
| 21 | assertTrue(columns.size() > 0); | 20 | assertTrue(columns.size() > 0); |
| 22 | } | 21 | } |
| 23 | 22 |
yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/dal/mysql/package-info.java
0 → 100644
yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/dal/package-info.java
0 → 100644
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java renamed to yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenEngineTest.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen; | 1 | package cn.iocoder.yudao.module.tool.service.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.server.BaseDbUnitTest; | ||
| 4 | -import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO; | ||
| 5 | -import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO; | ||
| 6 | -import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper; | ||
| 7 | -import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenTableMapper; | ||
| 8 | -import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenEngine; | 3 | +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; |
| 4 | +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; | ||
| 5 | +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.CodegenColumnMapper; | ||
| 6 | +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.CodegenTableMapper; | ||
| 7 | +import cn.iocoder.yudao.module.tool.service.codegen.inner.CodegenEngine; | ||
| 8 | +import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; | ||
| 9 | import org.junit.jupiter.api.Test; | 9 | import org.junit.jupiter.api.Test; |
| 10 | 10 | ||
| 11 | import javax.annotation.Resource; | 11 | import javax.annotation.Resource; |
| 12 | import java.util.List; | 12 | import java.util.List; |
| 13 | import java.util.Map; | 13 | import java.util.Map; |
| 14 | 14 | ||
| 15 | -public class ToolCodegenEngineTest extends BaseDbUnitTest { | 15 | +public class CodegenEngineTest extends BaseDbUnitTest { |
| 16 | 16 | ||
| 17 | @Resource | 17 | @Resource |
| 18 | - private ToolCodegenTableMapper codegenTableMapper; | 18 | + private CodegenTableMapper codegenTableMapper; |
| 19 | @Resource | 19 | @Resource |
| 20 | - private ToolCodegenColumnMapper codegenColumnMapper; | 20 | + private CodegenColumnMapper codegenColumnMapper; |
| 21 | 21 | ||
| 22 | @Resource | 22 | @Resource |
| 23 | - private ToolCodegenEngine codegenEngine; | 23 | + private CodegenEngine codegenEngine; |
| 24 | 24 | ||
| 25 | @Test | 25 | @Test |
| 26 | public void testExecute() { | 26 | public void testExecute() { |
| 27 | - ToolCodegenTableDO table = codegenTableMapper.selectById(20); | ||
| 28 | - List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId()); | 27 | + CodegenTableDO table = codegenTableMapper.selectById(20); |
| 28 | + List<CodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId()); | ||
| 29 | Map<String, String> result = codegenEngine.execute(table, columns); | 29 | Map<String, String> result = codegenEngine.execute(table, columns); |
| 30 | result.forEach((s, s2) -> System.out.println(s2)); | 30 | result.forEach((s, s2) -> System.out.println(s2)); |
| 31 | // System.out.println(result.get("vue/views/system/test/index.vue")); | 31 | // System.out.println(result.get("vue/views/system/test/index.vue")); |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java renamed to yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenSQLParserTest.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen; | 1 | package cn.iocoder.yudao.module.tool.service.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.server.BaseDbUnitTest; | ||
| 4 | -import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser; | 3 | +import cn.iocoder.yudao.module.tool.service.codegen.inner.CodegenSQLParser; |
| 4 | +import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; | ||
| 5 | import org.junit.jupiter.api.Test; | 5 | import org.junit.jupiter.api.Test; |
| 6 | 6 | ||
| 7 | -public class ToolCodegenSQLParserTest extends BaseDbUnitTest { | 7 | +public class CodegenSQLParserTest extends BaseDbUnitTest { |
| 8 | 8 | ||
| 9 | @Test | 9 | @Test |
| 10 | public void testParse() { | 10 | public void testParse() { |
| @@ -22,7 +22,7 @@ public class ToolCodegenSQLParserTest extends BaseDbUnitTest { | @@ -22,7 +22,7 @@ public class ToolCodegenSQLParserTest extends BaseDbUnitTest { | ||
| 22 | " `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',\n" + | 22 | " `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',\n" + |
| 23 | " PRIMARY KEY (`id`) USING BTREE\n" + | 23 | " PRIMARY KEY (`id`) USING BTREE\n" + |
| 24 | ") ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8mb4 COMMENT='字典类型表';"; | 24 | ") ENGINE=InnoDB AUTO_INCREMENT=108 DEFAULT CHARSET=utf8mb4 COMMENT='字典类型表';"; |
| 25 | - ToolCodegenSQLParser.parse(sql); | 25 | + CodegenSQLParser.parse(sql); |
| 26 | // TODO 芋艿:后续完善断言 | 26 | // TODO 芋艿:后续完善断言 |
| 27 | } | 27 | } |
| 28 | 28 |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java renamed to yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImplTest.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen; | 1 | package cn.iocoder.yudao.module.tool.service.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.server.BaseDbUnitTest; | ||
| 4 | -import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl; | 3 | +import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; |
| 5 | import org.junit.jupiter.api.Test; | 4 | import org.junit.jupiter.api.Test; |
| 6 | 5 | ||
| 7 | import javax.annotation.Resource; | 6 | import javax.annotation.Resource; |
| 8 | 7 | ||
| 9 | -class ToolCodegenServiceImplTest extends BaseDbUnitTest { | 8 | +class CodegenServiceImplTest extends BaseDbUnitTest { |
| 10 | 9 | ||
| 11 | @Resource | 10 | @Resource |
| 12 | - private ToolCodegenServiceImpl toolCodegenService; | 11 | + private CodegenServiceImpl codegenService; |
| 13 | 12 | ||
| 14 | @Test | 13 | @Test |
| 15 | public void tetCreateCodegenTable() { | 14 | public void tetCreateCodegenTable() { |
| 16 | - toolCodegenService.createCodegen("tool_test_demo"); | 15 | + codegenService.createCodegen(0L, "tool_test_demo"); |
| 17 | // toolCodegenService.createCodegenTable("tool_codegen_table"); | 16 | // toolCodegenService.createCodegenTable("tool_codegen_table"); |
| 18 | // toolCodegenService.createCodegen("tool_codegen_column"); | 17 | // toolCodegenService.createCodegen("tool_codegen_column"); |
| 19 | } | 18 | } |
yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/service/package-info.java
0 → 100644
yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/test/BaseDbAndRedisIntegrationTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.test; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; | ||
| 5 | +import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; | ||
| 6 | +import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; | ||
| 7 | +import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration; | ||
| 8 | +import org.redisson.spring.starter.RedissonAutoConfiguration; | ||
| 9 | +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; | ||
| 10 | +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
| 11 | +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; | ||
| 12 | +import org.springframework.boot.test.context.SpringBootTest; | ||
| 13 | +import org.springframework.context.annotation.Import; | ||
| 14 | +import org.springframework.test.context.ActiveProfiles; | ||
| 15 | + | ||
| 16 | +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisIntegrationTest.Application.class) | ||
| 17 | +@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 | ||
| 18 | +public class BaseDbAndRedisIntegrationTest { | ||
| 19 | + | ||
| 20 | + @Import({ | ||
| 21 | + // DB 配置类 | ||
| 22 | + DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类 | ||
| 23 | + YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类 | ||
| 24 | + DataSourceAutoConfiguration.class, // Spring DB 自动配置类 | ||
| 25 | + DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类 | ||
| 26 | + // MyBatis 配置类 | ||
| 27 | + YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类 | ||
| 28 | + MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类 | ||
| 29 | + | ||
| 30 | + // Redis 配置类 | ||
| 31 | + RedisAutoConfiguration.class, // Spring Redis 自动配置类 | ||
| 32 | + YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 | ||
| 33 | + RedissonAutoConfiguration.class, // Redisson 自动高配置类 | ||
| 34 | + }) | ||
| 35 | + public static class Application { | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | +} |
yudao-module-tool/yudao-module-tool-impl/src/test-integration/java/cn/iocoder/yudao/module/tool/test/BaseRedisIntegrationTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.test; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; | ||
| 4 | +import org.redisson.spring.starter.RedissonAutoConfiguration; | ||
| 5 | +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; | ||
| 6 | +import org.springframework.boot.test.context.SpringBootTest; | ||
| 7 | +import org.springframework.context.annotation.Import; | ||
| 8 | +import org.springframework.test.context.ActiveProfiles; | ||
| 9 | + | ||
| 10 | +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisIntegrationTest.Application.class) | ||
| 11 | +@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件 | ||
| 12 | +public class BaseRedisIntegrationTest { | ||
| 13 | + | ||
| 14 | + @Import({ | ||
| 15 | + // Redis 配置类 | ||
| 16 | + RedisAutoConfiguration.class, // Spring Redis 自动配置类 | ||
| 17 | + YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类 | ||
| 18 | + RedissonAutoConfiguration.class, // Redisson 自动高配置类 | ||
| 19 | + }) | ||
| 20 | + public static class Application { | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | +} |
yudao-module-tool/yudao-module-tool-impl/src/test-integration/resources/application-integration-test.yaml
0 → 100644
| 1 | +spring: | ||
| 2 | + main: | ||
| 3 | + lazy-initialization: true # 开启懒加载,加快速度 | ||
| 4 | + banner-mode: off # 单元测试,禁用 Banner | ||
| 5 | + | ||
| 6 | +--- #################### 数据库相关配置 #################### | ||
| 7 | + | ||
| 8 | +spring: | ||
| 9 | + # 数据源配置项 | ||
| 10 | + autoconfigure: | ||
| 11 | + exclude: | ||
| 12 | + - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 | ||
| 13 | + datasource: | ||
| 14 | + druid: # Druid 【监控】相关的全局配置 | ||
| 15 | + web-stat-filter: | ||
| 16 | + enabled: true | ||
| 17 | + stat-view-servlet: | ||
| 18 | + enabled: true | ||
| 19 | + allow: # 设置白名单,不填则允许所有访问 | ||
| 20 | + url-pattern: /druid/* | ||
| 21 | + login-username: # 控制台管理用户名和密码 | ||
| 22 | + login-password: | ||
| 23 | + filter: | ||
| 24 | + stat: | ||
| 25 | + enabled: true | ||
| 26 | + log-slow-sql: true # 慢 SQL 记录 | ||
| 27 | + slow-sql-millis: 100 | ||
| 28 | + merge-sql: true | ||
| 29 | + wall: | ||
| 30 | + config: | ||
| 31 | + multi-statement-allow: true | ||
| 32 | + dynamic: # 多数据源配置 | ||
| 33 | + druid: # Druid 【连接池】相关的全局配置 | ||
| 34 | + initial-size: 5 # 初始连接数 | ||
| 35 | + min-idle: 10 # 最小连接池数量 | ||
| 36 | + max-active: 20 # 最大连接池数量 | ||
| 37 | + max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 | ||
| 38 | + time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 | ||
| 39 | + min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 | ||
| 40 | + max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 | ||
| 41 | + validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 | ||
| 42 | + test-while-idle: true | ||
| 43 | + test-on-borrow: false | ||
| 44 | + test-on-return: false | ||
| 45 | + primary: master | ||
| 46 | + datasource: | ||
| 47 | + master: | ||
| 48 | + name: ruoyi-vue-pro | ||
| 49 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | ||
| 50 | + driver-class-name: com.mysql.jdbc.Driver | ||
| 51 | + username: root | ||
| 52 | + password: 123456 | ||
| 53 | + slave: # 模拟从库,可根据自己需要修改 | ||
| 54 | + name: ruoyi-vue-pro | ||
| 55 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT | ||
| 56 | + driver-class-name: com.mysql.jdbc.Driver | ||
| 57 | + username: root | ||
| 58 | + password: 123456 | ||
| 59 | + | ||
| 60 | + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 | ||
| 61 | + redis: | ||
| 62 | + host: 127.0.0.1 # 地址 | ||
| 63 | + port: 6379 # 端口 | ||
| 64 | + database: 0 # 数据库索引 | ||
| 65 | + | ||
| 66 | +mybatis: | ||
| 67 | + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 | ||
| 68 | + | ||
| 69 | +--- #################### 定时任务相关配置 #################### | ||
| 70 | + | ||
| 71 | +--- #################### 配置中心相关配置 #################### | ||
| 72 | + | ||
| 73 | +--- #################### 服务保障相关配置 #################### | ||
| 74 | + | ||
| 75 | +# Lock4j 配置项(单元测试,禁用 Lock4j) | ||
| 76 | + | ||
| 77 | +# Resilience4j 配置项 | ||
| 78 | +resilience4j: | ||
| 79 | + ratelimiter: | ||
| 80 | + instances: | ||
| 81 | + backendA: | ||
| 82 | + limit-for-period: 1 # 每个周期内,允许的请求数。默认为 50 | ||
| 83 | + limit-refresh-period: 60s # 每个周期的时长,单位:微秒。默认为 500 | ||
| 84 | + timeout-duration: 1s # 被限流时,阻塞等待的时长,单位:微秒。默认为 5s | ||
| 85 | + register-health-indicator: true # 是否注册到健康监测 | ||
| 86 | + | ||
| 87 | +--- #################### 监控相关配置 #################### | ||
| 88 | + | ||
| 89 | +--- #################### 芋道相关配置 #################### | ||
| 90 | + | ||
| 91 | +# 芋道配置项,设置当前项目所有自定义的配置 | ||
| 92 | +yudao: | ||
| 93 | + security: | ||
| 94 | + token-header: Authorization | ||
| 95 | + token-secret: abcdefghijklmnopqrstuvwxyz | ||
| 96 | + token-timeout: 1d | ||
| 97 | + session-timeout: 30m | ||
| 98 | + mock-enable: true | ||
| 99 | + mock-secret: test | ||
| 100 | + swagger: | ||
| 101 | + enable: false # 单元测试,禁用 Swagger | ||
| 102 | + file: | ||
| 103 | + base-path: http://127.0.0.1:${server.port}/${yudao.web.api-prefix}/file/get/ | ||
| 104 | + xss: | ||
| 105 | + enable: false | ||
| 106 | + exclude-urls: # 如下两个 url,仅仅是为了演示,去掉配置也没关系 | ||
| 107 | + - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 | ||
| 108 | + - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 |
yudao-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java deleted
| 1 | -package cn.iocoder.yudao.module.tool.dal.mysql.codegen; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.server.BaseDbUnitTest; | ||
| 4 | - | ||
| 5 | -import javax.annotation.Resource; | ||
| 6 | - | ||
| 7 | -class ToolInformationSchemaTableMapperTest extends BaseDbUnitTest { | ||
| 8 | - | ||
| 9 | - @Resource | ||
| 10 | - private ToolSchemaTableMapper toolInformationSchemaTableMapper; | ||
| 11 | - | ||
| 12 | -} |