更改为构造注入并完善方法注释

This commit is contained in:
thinkgem
2025-10-12 20:34:18 +08:00
parent 67b3649c15
commit 5426668cdb
30 changed files with 202 additions and 167 deletions

View File

@@ -20,7 +20,6 @@ import com.jeesite.modules.sys.dao.*;
import com.jeesite.modules.sys.entity.*;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@@ -36,18 +35,22 @@ import java.util.List;
@SpringBootTest(classes = ApplicationTest.class)
public class DaoMapperTest extends BaseSpringContextTests {
@Autowired
private PostDao postDao;
@Autowired
private UserDao userDao;
@Autowired
private AreaDao areaDao;
@Autowired
private CompanyDao companyDao;
@Autowired
private FileUploadDao fileUploadDao;
@Autowired
private EmpUserDao empUserDao;
private final PostDao postDao;
private final UserDao userDao;
private final AreaDao areaDao;
private final CompanyDao companyDao;
private final FileUploadDao fileUploadDao;
private final EmpUserDao empUserDao;
public DaoMapperTest(PostDao postDao, UserDao userDao, AreaDao areaDao, CompanyDao companyDao,
FileUploadDao fileUploadDao, EmpUserDao empUserDao) {
this.postDao = postDao;
this.userDao = userDao;
this.areaDao = areaDao;
this.companyDao = companyDao;
this.fileUploadDao = fileUploadDao;
this.empUserDao = empUserDao;
}
@Test
public void testTableAnnotation() throws Exception{

View File

@@ -4,18 +4,16 @@
*/
package com.jeesite.test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import com.jeesite.common.config.Global;
import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.tests.BaseSpringContextTests;
import com.jeesite.modules.gen.entity.GenTable;
import com.jeesite.modules.gen.entity.GenTableColumn;
import com.jeesite.modules.gen.service.GenTableService;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
/**
* 代码生成工具API
@@ -27,9 +25,12 @@ import com.jeesite.modules.gen.service.GenTableService;
@Rollback(false)
public class GenTableToolTest extends BaseSpringContextTests {
@Autowired
private GenTableService genTableService;
private final GenTableService genTableService;
public GenTableToolTest(GenTableService genTableService) {
this.genTableService = genTableService;
}
@Test
public void execute() throws Exception{
GenTable genTable = new GenTable();

View File

@@ -23,7 +23,6 @@ import com.jeesite.modules.sys.service.UserService;
import com.jeesite.modules.sys.utils.UserUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
@@ -41,11 +40,14 @@ import java.util.List;
@Rollback(false)
public class MsgPushTest extends BaseSpringContextTests {
@Autowired
private UserService userService;
@Autowired
private MsgTemplateService msgTemplateService;
private final UserService userService;
private final MsgTemplateService msgTemplateService;
public MsgPushTest(UserService userService, MsgTemplateService msgTemplateService) {
this.userService = userService;
this.msgTemplateService = msgTemplateService;
}
@Test
public void testSend(){
User user = UserUtils.get("system");