fix(接口测试): 修复插件丢失步骤执行抛出异常问题

--bug=1015245 --user=赵勇 【接口测试】批量执行的时候在批量执行弹框里选了环境,但是提示没有环境 https://www.tapd.cn/55049933/s/1210105
This commit is contained in:
fit2-zhao 2022-07-25 15:22:41 +08:00 committed by f2c-ci-robot[bot]
parent af20a94e4c
commit 4e29e0be8b
3 changed files with 18 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import io.metersphere.base.domain.ApiScenario;
import io.metersphere.base.domain.ApiScenarioWithBLOBs;
import io.metersphere.base.domain.Schedule;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.ResetOrderRequest;
@ -373,12 +374,22 @@ public class ApiAutomationController {
@PostMapping(value = "/checkScenarioEnv")
public boolean checkScenarioEnv(@RequestBody ApiScenarioWithBLOBs request) {
return apiAutomationService.checkScenarioEnv(request);
try {
return apiAutomationService.checkScenarioEnv(request);
} catch (Exception e) {
MSException.throwException("场景步骤解析错误,检查是否包含插件步骤!");
}
return false;
}
@GetMapping(value = "/checkScenarioEnv/{scenarioId}")
public boolean checkScenarioEnvByScenarioId(@PathVariable String scenarioId) {
return apiAutomationService.checkScenarioEnv(scenarioId);
try {
return apiAutomationService.checkScenarioEnv(scenarioId);
} catch (Exception e) {
MSException.throwException("场景步骤解析错误,检查是否包含插件步骤!");
}
return false;
}
@GetMapping("/follow/{scenarioId}")

View File

@ -347,8 +347,11 @@ public class ElementUtil {
public static void dataFormatting(JSONArray hashTree) {
for (int i = 0; i < hashTree.size(); i++) {
JSONObject element = hashTree.getJSONObject(i);
if (element == null) {
continue;
}
formatSampler(element);
if (element != null && element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) {
if (element.get("clazzName") == null && clazzMap.containsKey(element.getString("type"))) {
element.fluentPut("clazzName", clazzMap.get(element.getString("type")));
}
if (element.containsKey("hashTree")) {

View File

@ -311,7 +311,7 @@ public class ApiScenarioEnvService {
builder.append(apiScenarioWithBLOBs.getName()).append("; ");
}
} catch (Exception e) {
MSException.throwException("场景:" + builder.toString() + "运行环境未配置,请检查!");
MSException.throwException("场景:" +apiScenarioWithBLOBs.getName() +",步骤解析错误,检查是否包含插件步骤!");
}
}
if (builder.length() > 0) {