fix(测试跟踪): 公共用例复制报错

--bug=1027593 --user=王旭 【测试跟踪】新建功能用例-添加到公共用例库-切换项目-复制该用例-报错该模块下已存在该测试用例 https://www.tapd.cn/55049933/s/1392526
This commit is contained in:
WangXu10 2023-07-12 19:04:56 +08:00 committed by fit2-zhao
parent 73211d44a5
commit 4ce718eb9e

View File

@ -2179,11 +2179,13 @@ public class TestCaseService {
for (int i = 0; i < list.size(); i++) {
TestCaseWithBLOBs batchCopy = new TestCaseWithBLOBs();
BeanUtils.copyBean(batchCopy, list.get(i));
batchCopy.setNodeId(request.getNodeId());
batchCopy.setName("copy_" + batchCopy.getName());
batchCopy.setProjectId(SessionUtils.getCurrentProjectId());
checkTestCaseExist(batchCopy, false);
String oldTestCaseId = batchCopy.getId();
String id = UUID.randomUUID().toString();
batchCopy.setId(id);
batchCopy.setName("copy_" + batchCopy.getName());
if (batchCopy.getName().length() > 255) {
batchCopy.setName(batchCopy.getName().substring(0, 250) + batchCopy.getName().substring(batchCopy.getName().length() - 5));
}
@ -2194,14 +2196,12 @@ public class TestCaseService {
batchCopy.setReviewStatus(TestCaseReviewStatus.Prepare.name());
batchCopy.setStatus(TestCaseReviewStatus.Prepare.name());
batchCopy.setNodePath(StringUtils.EMPTY);
batchCopy.setNodeId(request.getNodeId());
batchCopy.setCasePublic(false);
batchCopy.setRefId(id);
if (!(batchCopy.getProjectId()).equals(SessionUtils.getCurrentProjectId())) {
String versionId = baseProjectVersionMapper.getDefaultVersion(SessionUtils.getCurrentProjectId());
batchCopy.setVersionId(versionId);
}
batchCopy.setProjectId(SessionUtils.getCurrentProjectId());
batchCopy.setOrder(nextOrder += ServiceUtils.ORDER_STEP);
batchCopy.setCustomNum(String.valueOf(nextNum));
batchCopy.setNum(nextNum++);