fix(接口测试): 解决场景覆盖导入报错以及创建case报错以及没有状态问题

--user=郭雨琦
--bug=1014815
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014815
--bug=1014816
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014816
--bug=1014820
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014820
--bug=1014814
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014814
This commit is contained in:
guoyuqi 2022-07-13 15:13:12 +08:00 committed by xiaomeinvG
parent 09efdf1119
commit b3d622b23d
4 changed files with 14 additions and 5 deletions

View File

@ -1211,7 +1211,7 @@ public class ApiAutomationService {
if (CollectionUtils.isEmpty(sameRequest)) {
scenarioWithBLOBs.setId(UUID.randomUUID().toString());
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
if (!scenarioWithBLOBs.getVersionId().equals("update")) {
if (scenarioWithBLOBs.getVersionId() != null && !scenarioWithBLOBs.getVersionId().equals("update")) {
scenarioWithBLOBs.setOrder(getImportNextOrder(apiTestImportRequest.getProjectId()));
// 导入时设置版本
scenarioWithBLOBs.setRefId(scenarioWithBLOBs.getId());
@ -1248,7 +1248,7 @@ public class ApiAutomationService {
scenarioWithBLOBs.setCreateTime(System.currentTimeMillis());
scenarioWithBLOBs.setVersionId(apiTestImportRequest.getUpdateVersionId());
scenarioWithBLOBs.setLatest(apiTestImportRequest.getVersionId().equals(apiTestImportRequest.getDefaultVersion()));
if (!scenarioWithBLOBs.getVersionId().equals("update")) {
if (scenarioWithBLOBs.getVersionId() != null && !scenarioWithBLOBs.getVersionId().equals("update")) {
scenarioWithBLOBs.setRefId(sameRequest.get(0).getRefId());
scenarioWithBLOBs.setNum(sameRequest.get(0).getNum()); // 使用第一个num当作本次的num
scenarioWithBLOBs.setOrder(sameRequest.get(0).getOrder());

View File

@ -853,11 +853,20 @@ public class ApiDefinitionService {
}
apiTestCaseWithBLOBs.setUpdateTime(System.currentTimeMillis());
if (StringUtils.isBlank(apiTestCaseWithBLOBs.getStatus())) {
apiTestCaseWithBLOBs.setStatus(APITestStatus.Underway.name());
apiTestCaseWithBLOBs.setStatus(APITestStatus.Prepare.name());
}
if (StringUtils.isBlank(apiTestCaseWithBLOBs.getCaseStatus())) {
apiTestCaseWithBLOBs.setCaseStatus(APITestStatus.Prepare.name());
}
if (StringUtils.isBlank(apiTestCaseWithBLOBs.getCreateUserId())) {
apiTestCaseWithBLOBs.setCreateUserId(apiDefinition.getUserId());
}
if (apiTestCaseWithBLOBs.getOrder() == null) {
apiTestCaseWithBLOBs.setOrder(getImportNextCaseOrder(apiDefinition.getProjectId()));
}
if (apiTestCaseWithBLOBs.getNum() == null) {
apiTestCaseWithBLOBs.setNum(testCaseService.getNextNum(apiDefinition.getId()));
}
if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) {
apiTestCaseMapper.updateByPrimaryKeyWithBLOBs(apiTestCaseWithBLOBs);
} else {

View File

@ -1,5 +1,5 @@
package io.metersphere.commons.constants;
public enum APITestStatus {
Saved, Starting, Running, Reporting, Completed, Debug, Error, Success,Underway,Waiting,Rerunning
Saved, Starting, Running, Reporting, Completed, Debug, Error, Success, Underway, Waiting, Rerunning, Prepare
}

View File

@ -1904,7 +1904,7 @@ public class TestCaseService {
*
* @return
*/
private int getNextNum(String projectId) {
public int getNextNum(String projectId) {
TestCase testCase = extTestCaseMapper.getMaxNumByProjectId(projectId);
if (testCase == null || testCase.getNum() == null) {
return 100001;