多模块重构 13:迁移集成测试~
parent
eb2ab3cc4d
commit
61672e0180
@ -1,52 +1,52 @@
|
||||
package cn.iocoder.yudao.server.framework.quartz.core;
|
||||
package cn.iocoder.yudao.module.system.job;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.server.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob;
|
||||
import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager;
|
||||
import cn.iocoder.yudao.module.system.job.auth.UserSessionTimeoutJob;
|
||||
import cn.iocoder.yudao.module.system.test.BaseDbUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.quartz.SchedulerException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
class SchedulerManagerTest extends BaseDbUnitTest {
|
||||
public class SchedulerManagerTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private SchedulerManager schedulerManager;
|
||||
|
||||
@Test
|
||||
public void testAddJob() throws SchedulerException {
|
||||
String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName());
|
||||
String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName());
|
||||
schedulerManager.addJob(1L, jobHandlerName, "test", "0/10 * * * * ? *", 0, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateJob() throws SchedulerException {
|
||||
String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName());
|
||||
String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName());
|
||||
schedulerManager.updateJob(jobHandlerName, "hahaha", "0/20 * * * * ? *", 0, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteJob() throws SchedulerException {
|
||||
String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName());
|
||||
String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName());
|
||||
schedulerManager.deleteJob(jobHandlerName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPauseJob() throws SchedulerException {
|
||||
String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName());
|
||||
String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName());
|
||||
schedulerManager.pauseJob(jobHandlerName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResumeJob() throws SchedulerException {
|
||||
String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName());
|
||||
String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName());
|
||||
schedulerManager.resumeJob(jobHandlerName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTriggerJob() throws SchedulerException {
|
||||
String jobHandlerName = StrUtil.lowerFirst(SysUserSessionTimeoutJob.class.getSimpleName());
|
||||
String jobHandlerName = StrUtil.lowerFirst(UserSessionTimeoutJob.class.getSimpleName());
|
||||
schedulerManager.triggerJob(1L, jobHandlerName, "niubi!!!");
|
||||
}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.system.service;
|
||||
@ -0,0 +1,38 @@
|
||||
package cn.iocoder.yudao.module.system.test;
|
||||
|
||||
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseDbAndRedisIntegrationTest.Application.class)
|
||||
@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件
|
||||
public class BaseDbAndRedisIntegrationTest {
|
||||
|
||||
@Import({
|
||||
// DB 配置类
|
||||
DynamicDataSourceAutoConfiguration.class, // Dynamic Datasource 配置类
|
||||
YudaoDataSourceAutoConfiguration.class, // 自己的 DB 配置类
|
||||
DataSourceAutoConfiguration.class, // Spring DB 自动配置类
|
||||
DataSourceTransactionManagerAutoConfiguration.class, // Spring 事务自动配置类
|
||||
// MyBatis 配置类
|
||||
YudaoMybatisAutoConfiguration.class, // 自己的 MyBatis 配置类
|
||||
MybatisPlusAutoConfiguration.class, // MyBatis 的自动配置类
|
||||
|
||||
// Redis 配置类
|
||||
RedisAutoConfiguration.class, // Spring Redis 自动配置类
|
||||
YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
|
||||
RedissonAutoConfiguration.class, // Redisson 自动高配置类
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.system.test;
|
||||
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = BaseRedisIntegrationTest.Application.class)
|
||||
@ActiveProfiles("integration-test") // 设置使用 application-integration-test 配置文件
|
||||
public class BaseRedisIntegrationTest {
|
||||
|
||||
@Import({
|
||||
// Redis 配置类
|
||||
RedisAutoConfiguration.class, // Spring Redis 自动配置类
|
||||
YudaoRedisAutoConfiguration.class, // 自己的 Redis 配置类
|
||||
RedissonAutoConfiguration.class, // Redisson 自动高配置类
|
||||
})
|
||||
public static class Application {
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package cn.iocoder.yudao.module.tool.dal.mysql.codegen;
|
||||
|
||||
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO;
|
||||
import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class SchemaColumnMapperTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private SchemaColumnMapper schemaColumnMapper;
|
||||
|
||||
@Test
|
||||
public void testSelectListByTableName() {
|
||||
List<SchemaColumnDO> columns = schemaColumnMapper.selectListByTableName("", "inf_config");
|
||||
assertTrue(columns.size() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.tool.dal.mysql;
|
||||
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.tool.dal;
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.tool.service.codegen;
|
||||
|
||||
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO;
|
||||
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO;
|
||||
import cn.iocoder.yudao.module.tool.dal.mysql.codegen.CodegenColumnMapper;
|
||||
import cn.iocoder.yudao.module.tool.dal.mysql.codegen.CodegenTableMapper;
|
||||
import cn.iocoder.yudao.module.tool.service.codegen.inner.CodegenEngine;
|
||||
import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CodegenEngineTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private CodegenTableMapper codegenTableMapper;
|
||||
@Resource
|
||||
private CodegenColumnMapper codegenColumnMapper;
|
||||
|
||||
@Resource
|
||||
private CodegenEngine codegenEngine;
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
CodegenTableDO table = codegenTableMapper.selectById(20);
|
||||
List<CodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId());
|
||||
Map<String, String> result = codegenEngine.execute(table, columns);
|
||||
result.forEach((s, s2) -> System.out.println(s2));
|
||||
// System.out.println(result.get("vue/views/system/test/index.vue"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,19 +1,18 @@
|
||||
package cn.iocoder.yudao.module.tool.service.codegen;
|
||||
|
||||
import cn.iocoder.yudao.server.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl;
|
||||
import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
class ToolCodegenServiceImplTest extends BaseDbUnitTest {
|
||||
class CodegenServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ToolCodegenServiceImpl toolCodegenService;
|
||||
private CodegenServiceImpl codegenService;
|
||||
|
||||
@Test
|
||||
public void tetCreateCodegenTable() {
|
||||
toolCodegenService.createCodegen("tool_test_demo");
|
||||
codegenService.createCodegen(0L, "tool_test_demo");
|
||||
// toolCodegenService.createCodegenTable("tool_codegen_table");
|
||||
// toolCodegenService.createCodegen("tool_codegen_column");
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
package cn.iocoder.yudao.module.tool.service;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.server;
|
||||
package cn.iocoder.yudao.module.tool.test;
|
||||
|
||||
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
|
||||
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;
|
||||
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.server;
|
||||
package cn.iocoder.yudao.module.tool.test;
|
||||
|
||||
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
|
||||
import org.redisson.spring.starter.RedissonAutoConfiguration;
|
||||
@ -1,24 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tool.dal.mysql.codegen;
|
||||
|
||||
import cn.iocoder.yudao.server.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ToolInformationSchemaColumnMapperTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ToolSchemaColumnMapper toolInformationSchemaColumnMapper;
|
||||
|
||||
@Test
|
||||
public void testSelectListByTableName() {
|
||||
List<ToolSchemaColumnDO> columns = toolInformationSchemaColumnMapper
|
||||
.selectListByTableName("", "inf_config");
|
||||
assertTrue(columns.size() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,12 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tool.dal.mysql.codegen;
|
||||
|
||||
import cn.iocoder.yudao.server.BaseDbUnitTest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
class ToolInformationSchemaTableMapperTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ToolSchemaTableMapper toolInformationSchemaTableMapper;
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package cn.iocoder.yudao.module.tool.service.codegen;
|
||||
|
||||
import cn.iocoder.yudao.server.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO;
|
||||
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO;
|
||||
import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper;
|
||||
import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenTableMapper;
|
||||
import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenEngine;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ToolCodegenEngineTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private ToolCodegenTableMapper codegenTableMapper;
|
||||
@Resource
|
||||
private ToolCodegenColumnMapper codegenColumnMapper;
|
||||
|
||||
@Resource
|
||||
private ToolCodegenEngine codegenEngine;
|
||||
|
||||
@Test
|
||||
public void testExecute() {
|
||||
ToolCodegenTableDO table = codegenTableMapper.selectById(20);
|
||||
List<ToolCodegenColumnDO> columns = codegenColumnMapper.selectListByTableId(table.getId());
|
||||
Map<String, String> result = codegenEngine.execute(table, columns);
|
||||
result.forEach((s, s2) -> System.out.println(s2));
|
||||
// System.out.println(result.get("vue/views/system/test/index.vue"));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue