feat(测试跟踪): 功能用例批量复制,bug修复
This commit is contained in:
parent
a27d3742f0
commit
70bb6a1a97
|
@ -94,7 +94,7 @@
|
||||||
project_version.id as versionId
|
project_version.id as versionId
|
||||||
from test_case
|
from test_case
|
||||||
left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId}
|
left join test_case_review_test_case as T2 on test_case.id=T2.case_id and T2.review_id =#{request.reviewId}
|
||||||
left join project_version on test_case.version_id = project_version.id and test_casel.project_id = project_version.project_id
|
left join project_version on test_case.version_id = project_version.id and test_case.project_id = project_version.project_id
|
||||||
<include refid="notInQueryWhereCondition"/>
|
<include refid="notInQueryWhereCondition"/>
|
||||||
and T2.case_id is null
|
and T2.case_id is null
|
||||||
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
<include refid="io.metersphere.base.mapper.ext.ExtBaseMapper.orders"/>
|
||||||
|
|
|
@ -34,6 +34,7 @@ import io.metersphere.track.request.testcase.TestCaseMinderEditRequest;
|
||||||
import io.metersphere.track.request.testplan.FileOperationRequest;
|
import io.metersphere.track.request.testplan.FileOperationRequest;
|
||||||
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
import io.metersphere.track.request.testplan.LoadCaseRequest;
|
||||||
import io.metersphere.track.service.TestCaseService;
|
import io.metersphere.track.service.TestCaseService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -210,6 +211,12 @@ public class TestCaseController {
|
||||||
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, targetClass = TestCaseMapper.class,
|
@SendNotice(taskType = NoticeConstants.TaskType.TRACK_TEST_CASE_TASK, targetClass = TestCaseMapper.class,
|
||||||
event = NoticeConstants.Event.CREATE, mailTemplate = "track/TestCaseCreate", subject = "测试用例通知")
|
event = NoticeConstants.Event.CREATE, mailTemplate = "track/TestCaseCreate", subject = "测试用例通知")
|
||||||
public TestCase addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
public TestCase addTestCase(@RequestPart("request") EditTestCaseRequest request, @RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
||||||
|
if(StringUtils.isBlank(request.getId())){
|
||||||
|
//新增 后端生成 id
|
||||||
|
request.setId(UUID.randomUUID().toString());
|
||||||
|
}else{
|
||||||
|
//复制,前端生成 id
|
||||||
|
}
|
||||||
return testCaseService.save(request, files);
|
return testCaseService.save(request, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ public class EditTestCaseRequest extends TestCaseWithBLOBs {
|
||||||
private List<FileMetadata> updatedFileList;
|
private List<FileMetadata> updatedFileList;
|
||||||
private List<String> follows;
|
private List<String> follows;
|
||||||
private OtherInfoConfig otherInfoConfig;
|
private OtherInfoConfig otherInfoConfig;
|
||||||
|
private String oldDataId;
|
||||||
/**
|
/**
|
||||||
* 复制测试用例后,要进行复制的文件Id list
|
* 复制测试用例后,要进行复制的文件Id list
|
||||||
*/
|
*/
|
||||||
|
@ -38,5 +39,16 @@ public class EditTestCaseRequest extends TestCaseWithBLOBs {
|
||||||
private boolean archive;
|
private boolean archive;
|
||||||
//是否复制依赖
|
//是否复制依赖
|
||||||
private boolean dependency;
|
private boolean dependency;
|
||||||
|
|
||||||
|
public static OtherInfoConfig createDefault() {
|
||||||
|
OtherInfoConfig o = new OtherInfoConfig();
|
||||||
|
o.setArchive(true);
|
||||||
|
o.setRemark(true);
|
||||||
|
o.setRelateTest(true);
|
||||||
|
o.setDependency(true);
|
||||||
|
o.setRelateDemand(true);
|
||||||
|
o.setRelateIssue(true);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,18 +194,11 @@ public class TestCaseService {
|
||||||
request.setCreateUser(SessionUtils.getUserId());
|
request.setCreateUser(SessionUtils.getUserId());
|
||||||
this.setNode(request);
|
this.setNode(request);
|
||||||
request.setOrder(ServiceUtils.getNextOrder(request.getProjectId(), extTestCaseMapper::getLastOrder));
|
request.setOrder(ServiceUtils.getNextOrder(request.getProjectId(), extTestCaseMapper::getLastOrder));
|
||||||
//直接点保存
|
//直接点保存 || 复制走的逻辑
|
||||||
if (StringUtils.isAllBlank(request.getRefId(), request.getVersionId())) {
|
if (StringUtils.isAllBlank(request.getRefId(), request.getVersionId())) {
|
||||||
//新创建测试用例,默认使用最新版本
|
//新创建测试用例,默认使用最新版本
|
||||||
request.setRefId(request.getId());
|
request.setRefId(request.getId());
|
||||||
ProjectVersionRequest pvr = new ProjectVersionRequest();
|
request.setVersionId(extProjectVersionMapper.getDefaultVersion(request.getProjectId()));
|
||||||
pvr.setProjectId(request.getProjectId());
|
|
||||||
pvr.setLatest(true);
|
|
||||||
List<ProjectVersionDTO> pvs = projectVersionService.getVersionList(pvr);
|
|
||||||
if (pvs.size() == 0) {
|
|
||||||
MSException.throwException(Translator.get("no_version_exists"));
|
|
||||||
}
|
|
||||||
request.setVersionId(pvs.get(0).getId());
|
|
||||||
} else if (StringUtils.isBlank(request.getRefId()) && StringUtils.isNotBlank(request.getVersionId())) {
|
} else if (StringUtils.isBlank(request.getRefId()) && StringUtils.isNotBlank(request.getVersionId())) {
|
||||||
//从版本选择直接创建
|
//从版本选择直接创建
|
||||||
request.setRefId(request.getId());
|
request.setRefId(request.getId());
|
||||||
|
@ -216,6 +209,14 @@ public class TestCaseService {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dealWithCopyOtherInfo(TestCaseWithBLOBs testCase, String oldTestCaseId) {
|
||||||
|
EditTestCaseRequest request = new EditTestCaseRequest();
|
||||||
|
BeanUtils.copyBean(request, testCase);
|
||||||
|
EditTestCaseRequest.OtherInfoConfig otherInfoConfig = EditTestCaseRequest.OtherInfoConfig.createDefault();
|
||||||
|
request.setOtherInfoConfig(otherInfoConfig);
|
||||||
|
DealWithOtherInfo(request, oldTestCaseId);
|
||||||
|
}
|
||||||
|
|
||||||
public void saveFollows(String caseId, List<String> follows) {
|
public void saveFollows(String caseId, List<String> follows) {
|
||||||
TestCaseFollowExample example = new TestCaseFollowExample();
|
TestCaseFollowExample example = new TestCaseFollowExample();
|
||||||
example.createCriteria().andCaseIdEqualTo(caseId);
|
example.createCriteria().andCaseIdEqualTo(caseId);
|
||||||
|
@ -302,7 +303,7 @@ public class TestCaseService {
|
||||||
testCase.setCreateUser(SessionUtils.getUserId());
|
testCase.setCreateUser(SessionUtils.getUserId());
|
||||||
testCase.setOrder(oldTestCase.getOrder());
|
testCase.setOrder(oldTestCase.getOrder());
|
||||||
testCase.setRefId(oldTestCase.getRefId());
|
testCase.setRefId(oldTestCase.getRefId());
|
||||||
DealWithOtherInfo(testCase, oldTestCase);
|
DealWithOtherInfo(testCase, oldTestCase.getId());
|
||||||
testCaseMapper.insertSelective(testCase);
|
testCaseMapper.insertSelective(testCase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,9 +312,9 @@ public class TestCaseService {
|
||||||
* 处理其他信息的复制问题
|
* 处理其他信息的复制问题
|
||||||
*
|
*
|
||||||
* @param testCase
|
* @param testCase
|
||||||
* @param oldTestCase
|
* @param oldTestCaseId
|
||||||
*/
|
*/
|
||||||
private void DealWithOtherInfo(EditTestCaseRequest testCase, TestCaseWithBLOBs oldTestCase) {
|
private void DealWithOtherInfo(EditTestCaseRequest testCase, String oldTestCaseId) {
|
||||||
EditTestCaseRequest.OtherInfoConfig otherInfoConfig = testCase.getOtherInfoConfig();
|
EditTestCaseRequest.OtherInfoConfig otherInfoConfig = testCase.getOtherInfoConfig();
|
||||||
if (otherInfoConfig != null) {
|
if (otherInfoConfig != null) {
|
||||||
if (!otherInfoConfig.isRemark()) {
|
if (!otherInfoConfig.isRemark()) {
|
||||||
|
@ -324,7 +325,7 @@ public class TestCaseService {
|
||||||
testCase.setDemandName(null);
|
testCase.setDemandName(null);
|
||||||
}
|
}
|
||||||
if (otherInfoConfig.isRelateIssue()) {
|
if (otherInfoConfig.isRelateIssue()) {
|
||||||
List<IssuesDao> issuesDaos = issuesService.getIssues(oldTestCase.getId());
|
List<IssuesDao> issuesDaos = issuesService.getIssues(oldTestCaseId);
|
||||||
if (CollectionUtils.isNotEmpty(issuesDaos)) {
|
if (CollectionUtils.isNotEmpty(issuesDaos)) {
|
||||||
issuesDaos.forEach(issue -> {
|
issuesDaos.forEach(issue -> {
|
||||||
TestCaseIssues t = new TestCaseIssues();
|
TestCaseIssues t = new TestCaseIssues();
|
||||||
|
@ -336,7 +337,7 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (otherInfoConfig.isRelateTest()) {
|
if (otherInfoConfig.isRelateTest()) {
|
||||||
List<TestCaseTestDao> testCaseTestDaos = getRelateTest(oldTestCase.getId());
|
List<TestCaseTestDao> testCaseTestDaos = getRelateTest(oldTestCaseId);
|
||||||
if (CollectionUtils.isNotEmpty(testCaseTestDaos)) {
|
if (CollectionUtils.isNotEmpty(testCaseTestDaos)) {
|
||||||
testCaseTestDaos.forEach(test -> {
|
testCaseTestDaos.forEach(test -> {
|
||||||
test.setTestCaseId(testCase.getId());
|
test.setTestCaseId(testCase.getId());
|
||||||
|
@ -345,7 +346,7 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (otherInfoConfig.isArchive()) {
|
if (otherInfoConfig.isArchive()) {
|
||||||
List<FileMetadata> files = fileService.getFileMetadataByCaseId(oldTestCase.getId());
|
List<FileMetadata> files = fileService.getFileMetadataByCaseId(oldTestCaseId);
|
||||||
if (CollectionUtils.isNotEmpty(files)) {
|
if (CollectionUtils.isNotEmpty(files)) {
|
||||||
files.forEach(file -> {
|
files.forEach(file -> {
|
||||||
TestCaseFile testCaseFile = new TestCaseFile();
|
TestCaseFile testCaseFile = new TestCaseFile();
|
||||||
|
@ -356,8 +357,8 @@ public class TestCaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (otherInfoConfig.isDependency()) {
|
if (otherInfoConfig.isDependency()) {
|
||||||
List<RelationshipEdge> preRelations = relationshipEdgeService.getRelationshipEdgeByType(testCase.getId(), "PRE");
|
List<RelationshipEdge> preRelations = relationshipEdgeService.getRelationshipEdgeByType(oldTestCaseId, "PRE");
|
||||||
List<RelationshipEdge> postRelations = relationshipEdgeService.getRelationshipEdgeByType(testCase.getId(), "POST");
|
List<RelationshipEdge> postRelations = relationshipEdgeService.getRelationshipEdgeByType(oldTestCaseId, "POST");
|
||||||
if (CollectionUtils.isNotEmpty(preRelations)) {
|
if (CollectionUtils.isNotEmpty(preRelations)) {
|
||||||
preRelations.forEach(relation -> {
|
preRelations.forEach(relation -> {
|
||||||
relation.setSourceId(testCase.getId());
|
relation.setSourceId(testCase.getId());
|
||||||
|
@ -2351,6 +2352,7 @@ public class TestCaseService {
|
||||||
for (int i = 0; i < testCases.size(); i++) {
|
for (int i = 0; i < testCases.size(); i++) {
|
||||||
TestCaseWithBLOBs testCase = testCases.get(i);
|
TestCaseWithBLOBs testCase = testCases.get(i);
|
||||||
String id = UUID.randomUUID().toString();
|
String id = UUID.randomUUID().toString();
|
||||||
|
String oldTestCaseId = testCase.getId();
|
||||||
testCase.setId(id);
|
testCase.setId(id);
|
||||||
testCase.setName(ServiceUtils.getCopyName(testCase.getName()));
|
testCase.setName(ServiceUtils.getCopyName(testCase.getName()));
|
||||||
testCase.setNodeId(request.getNodeId());
|
testCase.setNodeId(request.getNodeId());
|
||||||
|
@ -2361,6 +2363,8 @@ public class TestCaseService {
|
||||||
testCase.setCasePublic(false);
|
testCase.setCasePublic(false);
|
||||||
testCase.setRefId(id);
|
testCase.setRefId(id);
|
||||||
mapper.insert(testCase);
|
mapper.insert(testCase);
|
||||||
|
|
||||||
|
dealWithCopyOtherInfo(testCase, oldTestCaseId);
|
||||||
if (i % 50 == 0)
|
if (i % 50 == 0)
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 55185992835336919a043dea80bff34c4894790d
|
Subproject commit b35dfb7f4571ed9e9496ff67339b9118232b4bbd
|
|
@ -1 +1 @@
|
||||||
Subproject commit b0f7c4da991c1d3568751d6ccc08de8319e73fa4
|
Subproject commit 8b60bbae9617eed3903ffc847a20ecd9b22c4fe8
|
Loading…
Reference in New Issue