mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 21:49:23 +08:00
fix(测试跟踪): 功能用例保存重复检验失效
--bug=1027457 --user=陈建星 【测试跟踪】功能用例创建-同一模块下保存了内容一样的多个用例 https://www.tapd.cn/55049933/s/1388171
This commit is contained in:
parent
17238af777
commit
475fda0d79
@ -303,6 +303,8 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||
}
|
||||
|
||||
private void validateDbExist(TestCaseExcelData data, StringBuilder stringBuilder) {
|
||||
// 校验模块是否存在,没有存在则新建一个模块
|
||||
testCaseNodeService.createNodeByNodePath(data.getNodePath(), request.getProjectId(), nodeTrees, pathMap);
|
||||
if (this.isUpdateModel()) {
|
||||
return;
|
||||
}
|
||||
@ -313,10 +315,7 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener<Map<Integ
|
||||
String steps = getSteps(data);
|
||||
testCase.setSteps(steps);
|
||||
|
||||
// 校验模块是否存在,没有存在则新建一个模块
|
||||
testCaseNodeService.createNodeByNodePath(testCase.getNodePath(), request.getProjectId(), nodeTrees, pathMap);
|
||||
testCase.setNodeId(pathMap.get(testCase.getNodePath()));
|
||||
|
||||
boolean dbExist = testCaseService.exist(testCase);
|
||||
boolean excelExist = false;
|
||||
|
||||
|
@ -211,7 +211,7 @@ public class TestCaseService {
|
||||
|
||||
public TestCaseWithBLOBs addTestCase(EditTestCaseRequest request) {
|
||||
request.setName(request.getName());
|
||||
checkTestCaseExist(request);
|
||||
checkTestCaseExist(request, false);
|
||||
request.setId(request.getId());
|
||||
request.setCreateTime(System.currentTimeMillis());
|
||||
request.setUpdateTime(System.currentTimeMillis());
|
||||
@ -455,6 +455,7 @@ public class TestCaseService {
|
||||
// latest 字段 createNewVersionOrNot 已经设置过了,不更新
|
||||
testCase.setLatest(null);
|
||||
|
||||
checkTestCaseExist(testCase, true);
|
||||
testCaseMapper.updateByPrimaryKeySelective(testCase);
|
||||
|
||||
TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCase.getId());
|
||||
@ -614,7 +615,7 @@ public class TestCaseService {
|
||||
}
|
||||
}
|
||||
|
||||
public TestCaseWithBLOBs checkTestCaseExist(TestCaseWithBLOBs testCase) {
|
||||
public void checkTestCaseExist(TestCaseWithBLOBs testCase, boolean isEdit) {
|
||||
|
||||
// 全部字段值相同才判断为用例存在
|
||||
if (testCase != null) {
|
||||
@ -634,7 +635,7 @@ public class TestCaseService {
|
||||
if (StringUtils.isNotBlank(testCase.getTestId())) {
|
||||
criteria.andTestIdEqualTo(testCase.getTestId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(testCase.getId())) {
|
||||
if (isEdit && StringUtils.isNotBlank(testCase.getId())) {
|
||||
criteria.andIdNotEqualTo(testCase.getId());
|
||||
}
|
||||
List<TestCaseWithBLOBs> caseList = testCaseMapper.selectByExampleWithBLOBs(example);
|
||||
@ -649,13 +650,11 @@ public class TestCaseService {
|
||||
String remark = tc.getRemark() == null ? StringUtils.EMPTY : tc.getRemark();
|
||||
String prerequisite = tc.getPrerequisite() == null ? StringUtils.EMPTY : tc.getPrerequisite();
|
||||
if (StringUtils.equals(steps, caseSteps) && StringUtils.equals(remark, caseRemark) && StringUtils.equals(prerequisite, casePrerequisite)) {
|
||||
//MSException.throwException(Translator.get("test_case_already_exists"));
|
||||
return tc;
|
||||
MSException.throwException(Translator.get("test_case_already_exists_in_module"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2176,7 +2175,7 @@ public class TestCaseService {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
TestCaseWithBLOBs batchCopy = new TestCaseWithBLOBs();
|
||||
BeanUtils.copyBean(batchCopy, list.get(i));
|
||||
checkTestCaseExist(batchCopy);
|
||||
checkTestCaseExist(batchCopy, false);
|
||||
String oldTestCaseId = batchCopy.getId();
|
||||
String id = UUID.randomUUID().toString();
|
||||
batchCopy.setId(id);
|
||||
@ -2307,15 +2306,11 @@ public class TestCaseService {
|
||||
* @return
|
||||
*/
|
||||
public boolean exist(TestCaseWithBLOBs testCaseWithBLOBs) {
|
||||
|
||||
try {
|
||||
TestCaseWithBLOBs caseWithBLOBs = checkTestCaseExist(testCaseWithBLOBs);
|
||||
if (caseWithBLOBs != null)
|
||||
return true;
|
||||
checkTestCaseExist(testCaseWithBLOBs, testCaseWithBLOBs.getId() == null ? true : false);
|
||||
} catch (MSException e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,7 @@ test_case_import_template_sheet=Template
|
||||
module_not_null=The module must not be blank
|
||||
user_not_exists=The user in this project is not exists
|
||||
test_case_already_exists=The test case in this project is exists
|
||||
test_case_already_exists_in_module=The test case in this module is exists
|
||||
parse_data_error=Parse data error
|
||||
missing_header_information=Missing header information
|
||||
test_case_exist=A test case already exists under this project:
|
||||
|
@ -70,6 +70,7 @@ test_case_import_template_sheet=模版
|
||||
module_not_null=所属模块不能为空格
|
||||
user_not_exists=该项目下无该用户
|
||||
test_case_already_exists=该项目下已存在该测试用例
|
||||
test_case_already_exists_in_module=该模块下已存在该测试用例
|
||||
parse_data_error=解析数据出错
|
||||
missing_header_information=缺少头部信息
|
||||
test_case_exist=该项目下已存在用例:
|
||||
|
@ -70,6 +70,7 @@ test_case_import_template_sheet=模版
|
||||
module_not_null=所屬模塊不能為空格
|
||||
user_not_exists=該項目下無該用戶
|
||||
test_case_already_exists=該項目下已存在該測試用例
|
||||
test_case_already_exists_in_module=該模塊下已存在該測試用例
|
||||
parse_data_error=解析數據出錯
|
||||
missing_header_information=缺少頭部信息
|
||||
test_case_exist=該項目下已存在用例:
|
||||
|
Loading…
Reference in New Issue
Block a user