fix(测试计划): 对执行接口增加保护 #1005622

--bug=1005622 --user=赵勇 /test/plan/scenario/... https://www.tapd.cn/55049933/s/1032858
This commit is contained in:
fit2-zhao 2021-08-05 19:29:45 +08:00 committed by fit2-zhao
parent a1c7a369d3
commit 1135a89589
1 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.TestPlanMapper;
import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper; import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper;
import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.ApiRunMode;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.ServiceUtils;
import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.OperatingLogDetails;
import io.metersphere.service.ProjectService; import io.metersphere.service.ProjectService;
@ -141,6 +142,9 @@ public class TestPlanScenarioCaseService {
} }
} }
testPlanScenarioRequest.setPlanCaseIds(planCaseIdList); testPlanScenarioRequest.setPlanCaseIds(planCaseIdList);
if (CollectionUtils.isEmpty(planCaseIdList)) {
MSException.throwException("未找到执行场景!");
}
planCaseIdList.forEach(item -> { planCaseIdList.forEach(item -> {
idStr.append("\"").append(item).append("\"").append(","); idStr.append("\"").append(item).append("\"").append(",");
}); });
@ -151,7 +155,9 @@ public class TestPlanScenarioCaseService {
scenarioIds.add(apiScenario.getApiScenarioId()); scenarioIds.add(apiScenario.getApiScenarioId());
scenarioIdApiScarionMap.put(apiScenario.getApiScenarioId(), apiScenario.getId()); scenarioIdApiScarionMap.put(apiScenario.getApiScenarioId(), apiScenario.getId());
} }
if(scenarioIdApiScarionMap.isEmpty()){
MSException.throwException("未找到执行场景!");
}
RunScenarioRequest request = new RunScenarioRequest(); RunScenarioRequest request = new RunScenarioRequest();
request.setIds(scenarioIds); request.setIds(scenarioIds);
request.setReportId(testPlanScenarioRequest.getId()); request.setReportId(testPlanScenarioRequest.getId());