diff --git a/pom.xml b/pom.xml index 3ac5d30a5..2acee5316 100644 --- a/pom.xml +++ b/pom.xml @@ -61,7 +61,7 @@ maven-surefire-plugin ${maven-surefire-plugin.version} - + org.apache.maven.plugins maven-compiler-plugin diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml index ddad7ace2..b35fb283e 100644 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml +++ b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/application-unit-test.yaml @@ -36,3 +36,6 @@ mybatis: --- #################### 芋道相关配置 #################### # 芋道配置项,设置当前项目所有自定义的配置 +yudao: + info: + base-package: cn.iocoder.yudao.module diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback-spring.xml b/yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback.xml similarity index 100% rename from yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback-spring.xml rename to yudao-module-bpm/yudao-module-bpm-base/src/test/resources/logback.xml diff --git a/yudao-module-infra/yudao-module-infra-impl/pom.xml b/yudao-module-infra/yudao-module-infra-impl/pom.xml index 6cefa7028..67dda6647 100644 --- a/yudao-module-infra/yudao-module-infra-impl/pom.xml +++ b/yudao-module-infra/yudao-module-infra-impl/pom.xml @@ -103,26 +103,4 @@ - - - ${artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - repackage - - - - - - - diff --git a/yudao-module-member/yudao-module-member-impl/src/test/resources/file/erweima.jpg b/yudao-module-infra/yudao-module-infra-impl/src/test/resources/file/erweima.jpg similarity index 100% rename from yudao-module-member/yudao-module-member-impl/src/test/resources/file/erweima.jpg rename to yudao-module-infra/yudao-module-infra-impl/src/test/resources/file/erweima.jpg diff --git a/yudao-module-infra/yudao-module-infra-impl/src/test/resources/logback-spring.xml b/yudao-module-infra/yudao-module-infra-impl/src/test/resources/logback.xml similarity index 100% rename from yudao-module-infra/yudao-module-infra-impl/src/test/resources/logback-spring.xml rename to yudao-module-infra/yudao-module-infra-impl/src/test/resources/logback.xml diff --git a/yudao-module-infra/yudao-module-infra-impl/src/test/resources/sql/create_tables.sql b/yudao-module-infra/yudao-module-infra-impl/src/test/resources/sql/create_tables.sql index a47cc30b3..c203865f2 100644 --- a/yudao-module-infra/yudao-module-infra-impl/src/test/resources/sql/create_tables.sql +++ b/yudao-module-infra/yudao-module-infra-impl/src/test/resources/sql/create_tables.sql @@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS "infra_api_access_log" ( ) COMMENT 'API 访问日志表'; CREATE TABLE IF NOT EXISTS "infra_api_error_log" ( - "id" integer not null GENERATED BY DEFAULT AS IDENTITY, + "id" bigint not null GENERATED BY DEFAULT AS IDENTITY, "trace_id" varchar(64) not null, "user_id" bigint not null default '0', "user_type" tinyint not null default '0', diff --git a/yudao-module-member/yudao-module-member-impl/pom.xml b/yudao-module-member/yudao-module-member-impl/pom.xml index 9307d30d4..6029a8b2b 100644 --- a/yudao-module-member/yudao-module-member-impl/pom.xml +++ b/yudao-module-member/yudao-module-member-impl/pom.xml @@ -81,26 +81,4 @@ - - - ${artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - repackage - - - - - - - diff --git a/yudao-module-member/yudao-module-member-impl/src/test/resources/logback-spring.xml b/yudao-module-member/yudao-module-member-impl/src/test/resources/logback.xml similarity index 100% rename from yudao-module-member/yudao-module-member-impl/src/test/resources/logback-spring.xml rename to yudao-module-member/yudao-module-member-impl/src/test/resources/logback.xml diff --git a/yudao-module-pay/yudao-module-pay-impl/pom.xml b/yudao-module-pay/yudao-module-pay-impl/pom.xml index cb5821b8b..55a254484 100644 --- a/yudao-module-pay/yudao-module-pay-impl/pom.xml +++ b/yudao-module-pay/yudao-module-pay-impl/pom.xml @@ -78,26 +78,4 @@ - - - ${artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - repackage - - - - - - - diff --git a/yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback-spring.xml b/yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback.xml similarity index 100% rename from yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback-spring.xml rename to yudao-module-pay/yudao-module-pay-impl/src/test/resources/logback.xml diff --git a/yudao-module-system/yudao-module-system-impl/pom.xml b/yudao-module-system/yudao-module-system-impl/pom.xml index ecf9d967f..eb0e53e15 100644 --- a/yudao-module-system/yudao-module-system-impl/pom.xml +++ b/yudao-module-system/yudao-module-system-impl/pom.xml @@ -98,26 +98,4 @@ - - - ${artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - repackage - - - - - - - diff --git a/yudao-module-system/yudao-module-system-impl/src/test/resources/logback-spring.xml b/yudao-module-system/yudao-module-system-impl/src/test/resources/logback.xml similarity index 100% rename from yudao-module-system/yudao-module-system-impl/src/test/resources/logback-spring.xml rename to yudao-module-system/yudao-module-system-impl/src/test/resources/logback.xml diff --git a/yudao-module-tool/yudao-module-tool-impl/pom.xml b/yudao-module-tool/yudao-module-tool-impl/pom.xml index d1e68b291..4d8cb4876 100644 --- a/yudao-module-tool/yudao-module-tool-impl/pom.xml +++ b/yudao-module-tool/yudao-module-tool-impl/pom.xml @@ -79,26 +79,4 @@ - - - ${artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - repackage - - - - - - - diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java index ac857e715..a82f7528f 100755 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java @@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; -import java.util.Date; - /** * 字典类型 DO * @@ -46,25 +44,5 @@ public class TestDemoDO extends BaseDO { * 备注 */ private String remark; - /** - * 创建者 - */ - private String creator; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新者 - */ - private String updater; - /** - * 更新时间 - */ - private Date updateTime; - /** - * 是否删除 - */ - private Boolean deleted; } diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java index dc5f0ecbf..4914b3d22 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.tool.service.codegen.inner; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; @@ -96,7 +96,7 @@ public class CodegenBuilder { .build(); static { - Arrays.stream(TenantBaseDO.class.getDeclaredFields()).forEach(field -> BASE_DO_FIELDS.add(field.getName())); + Arrays.stream(ReflectUtil.getFields(TenantBaseDO.class)).forEach(field -> BASE_DO_FIELDS.add(field.getName())); // 处理 OPERATION 相关的字段 CREATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); UPDATE_OPERATION_EXCLUDE_COLUMN.addAll(BASE_DO_FIELDS); diff --git a/yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImplTest.java b/yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImplTest.java index c04ddb682..b8a2c86c8 100755 --- a/yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImplTest.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/test/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImplTest.java @@ -1,34 +1,34 @@ package cn.iocoder.yudao.module.tool.service.test; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - -import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; -import cn.iocoder.yudao.module.tool.controller.admin.test.vo.*; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.date.DateUtils; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; import cn.iocoder.yudao.module.tool.dal.mysql.test.TestDemoMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.tool.test.BaseDbUnitTest; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; +import java.util.List; -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.TEST_DEMO_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; /** -* {@link TestDemoServiceImpl} 的单元测试类 -* -* @author 芋道源码 -*/ + * {@link TestDemoServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ @Import(TestDemoServiceImpl.class) public class TestDemoServiceImplTest extends BaseDbUnitTest { @@ -88,8 +88,8 @@ public class TestDemoServiceImplTest extends BaseDbUnitTest { // 调用 testDemoService.deleteTestDemo(id); - // 校验数据不存在了 - assertNull(testDemoMapper.selectById(id)); + // 校验数据不存在了 + assertNull(testDemoMapper.selectById(id)); } @Test @@ -101,87 +101,87 @@ public class TestDemoServiceImplTest extends BaseDbUnitTest { assertServiceException(() -> testDemoService.deleteTestDemo(id), TEST_DEMO_NOT_EXISTS); } - @Test // TODO 请修改 null 为需要的值 + @Test public void testGetTestDemoPage() { - // mock 数据 - TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setType(null); - o.setCategory(null); - o.setRemark(null); - o.setCreateTime(null); - }); - testDemoMapper.insert(dbTestDemo); - // 测试 name 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName(null))); - // 测试 status 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(null))); - // 测试 type 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(null))); - // 测试 category 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(null))); - // 测试 remark 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(null))); - // 准备参数 - TestDemoPageReqVO reqVO = new TestDemoPageReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setType(null); - reqVO.setCategory(null); - reqVO.setRemark(null); - reqVO.setBeginCreateTime(null); - reqVO.setEndCreateTime(null); + // mock 数据 + TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 + o.setName("芋道源码"); + o.setStatus(CommonStatusEnum.ENABLE.getStatus()); + o.setType(1); + o.setCategory(2); + o.setRemark("哈哈哈"); + o.setCreateTime(DateUtils.buildTime(2021, 11, 11)); + }); + testDemoMapper.insert(dbTestDemo); + // 测试 name 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName("不匹配"))); + // 测试 status 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); + // 测试 type 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(2))); + // 测试 category 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(1))); + // 测试 remark 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark("呵呵呵"))); + // 测试 createTime 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(DateUtils.buildTime(2021, 12, 12)))); + // 准备参数 + TestDemoPageReqVO reqVO = new TestDemoPageReqVO(); + reqVO.setName("芋道"); + reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); + reqVO.setType(1); + reqVO.setCategory(2); + reqVO.setRemark("哈哈哈"); + reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 11, 10)); + reqVO.setEndCreateTime(DateUtils.buildTime(2021, 11, 12)); - // 调用 - PageResult pageResult = testDemoService.getTestDemoPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbTestDemo, pageResult.getList().get(0)); + // 调用 + PageResult pageResult = testDemoService.getTestDemoPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbTestDemo, pageResult.getList().get(0)); } - @Test // TODO 请修改 null 为需要的值 + @Test public void testGetTestDemoList() { - // mock 数据 - TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatus(null); - o.setType(null); - o.setCategory(null); - o.setRemark(null); - o.setCreateTime(null); - }); - testDemoMapper.insert(dbTestDemo); - // 测试 name 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName(null))); - // 测试 status 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(null))); - // 测试 type 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(null))); - // 测试 category 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(null))); - // 测试 remark 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(null))); - // 准备参数 - TestDemoExportReqVO reqVO = new TestDemoExportReqVO(); - reqVO.setName(null); - reqVO.setStatus(null); - reqVO.setType(null); - reqVO.setCategory(null); - reqVO.setRemark(null); - reqVO.setBeginCreateTime(null); - reqVO.setEndCreateTime(null); + // mock 数据 + TestDemoDO dbTestDemo = randomPojo(TestDemoDO.class, o -> { // 等会查询到 + o.setName("芋道源码"); + o.setStatus(CommonStatusEnum.ENABLE.getStatus()); + o.setType(1); + o.setCategory(2); + o.setRemark("哈哈哈"); + o.setCreateTime(DateUtils.buildTime(2021, 11, 11)); + }); + testDemoMapper.insert(dbTestDemo); + // 测试 name 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setName("不匹配"))); + // 测试 status 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus()))); + // 测试 type 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setType(2))); + // 测试 category 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCategory(1))); + // 测试 remark 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setRemark("呵呵呵"))); + // 测试 createTime 不匹配 + testDemoMapper.insert(cloneIgnoreId(dbTestDemo, o -> o.setCreateTime(DateUtils.buildTime(2021, 12, 12)))); + // 准备参数 + TestDemoExportReqVO reqVO = new TestDemoExportReqVO(); + reqVO.setName("芋道"); + reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); + reqVO.setType(1); + reqVO.setCategory(2); + reqVO.setRemark("哈哈哈"); + reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 11, 10)); + reqVO.setEndCreateTime(DateUtils.buildTime(2021, 11, 12)); - // 调用 - List list = testDemoService.getTestDemoList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbTestDemo, list.get(0)); + // 调用 + List list = testDemoService.getTestDemoList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbTestDemo, list.get(0)); } }