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