From 5c72885c916595fd14b82f9f5fd2b33c0304f351 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 27 Oct 2022 14:48:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=AF=BC=E5=85=A5=E7=9A=84=E7=94=A8=E4=BE=8B?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=A4=B1=E8=B4=A5=E9=87=8D=E8=B7=91=E6=97=A0?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/exec/api/ApiCaseSerialService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java index 5689a36375..9282728e10 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java +++ b/api-test/backend/src/main/java/io/metersphere/api/exec/api/ApiCaseSerialService.java @@ -130,7 +130,6 @@ public class ApiCaseSerialService { envId = envMap.get(caseWithBLOBs.getProjectId()); } if (caseWithBLOBs != null) { - String data = caseWithBLOBs.getRequest(); HashTree jmeterHashTree = new HashTree(); MsTestPlan testPlan = new MsTestPlan(); @@ -152,6 +151,10 @@ public class ApiCaseSerialService { } group.setProjectId(caseWithBLOBs.getProjectId()); MsTestElement testElement; + // 数据兼容处理 + JSONObject element = JSONUtil.parseObject(caseWithBLOBs.getRequest()); + ElementUtil.dataFormatting(element); + String data = element.toString(); if (runRequest.isRetryEnable() && runRequest.getRetryNum() > 0) { // 失败重试 ApiRetryOnFailureService apiRetryOnFailureService = CommonBeanFactory.getBean(ApiRetryOnFailureService.class); @@ -159,9 +162,9 @@ public class ApiCaseSerialService { data = StringUtils.isNotEmpty(retryData) ? retryData : data; // 格式化数据 testElement = apiRetryOnFailureService.retryParse(data); - MsTestElement element = parse(JSON.toJSONString(testElement.getHashTree().get(0)), testId, envId, caseWithBLOBs.getProjectId()); + MsTestElement msTestElement = parse(JSON.toJSONString(testElement.getHashTree().get(0)), testId, envId, caseWithBLOBs.getProjectId()); testElement.setHashTree(new LinkedList<>() {{ - this.add(element); + this.add(msTestElement); }}); } else { testElement = parse(data, testId, envId, caseWithBLOBs.getProjectId()); @@ -171,7 +174,6 @@ public class ApiCaseSerialService { group.getHashTree().add(testElement); testPlan.getHashTree().add(group); testPlan.toHashTree(jmeterHashTree, testPlan.getHashTree(), new ParameterConfig()); - LoggerUtil.info("用例资源:" + caseWithBLOBs.getName() + ", 生成执行脚本JMX成功", runRequest.getReportId()); return jmeterHashTree; } @@ -189,8 +191,6 @@ public class ApiCaseSerialService { private MsTestElement parse(String api, String planId, String envId, String projectId) { try { JSONObject element = JSONUtil.parseObject(api); - ElementUtil.dataFormatting(element); - LinkedList list = new LinkedList<>(); if (element != null && StringUtils.isNotEmpty(element.optString(ElementConstants.HASH_TREE))) { LinkedList elements = mapper.readValue(element.optString(ElementConstants.HASH_TREE),