From a30c790a41e1b668a8a4146f2c93d1f1353c7c73 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 3 Mar 2021 17:28:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=85=A5jmx=20JSON=20?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/automation/parse/MsJmeterParser.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java index 3ebe7dc027..1aef53d6dd 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/parse/MsJmeterParser.java @@ -48,6 +48,7 @@ import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.jmeter.assertions.*; import org.apache.jmeter.config.ConfigTestElement; import org.apache.jmeter.control.ForeachController; @@ -439,11 +440,20 @@ public class MsJmeterParser extends ApiImportAbstractParser { extract.getXpath().add(xPath); } else if (key instanceof JSONPostProcessor) { JSONPostProcessor jsonPostProcessor = (JSONPostProcessor) key; - MsExtractJSONPath jsonPath = new MsExtractJSONPath(); - jsonPath.setVariable(jsonPostProcessor.getRefNames()); - jsonPath.setExpression(jsonPostProcessor.getJsonPathExpressions()); - extract.setName(jsonPostProcessor.getName()); - extract.getJson().add(jsonPath); + String[] names = StringUtils.isNotEmpty(jsonPostProcessor.getRefNames()) ? jsonPostProcessor.getRefNames().split(";") : null; + String[] values = StringUtils.isNotEmpty(jsonPostProcessor.getJsonPathExpressions()) ? jsonPostProcessor.getJsonPathExpressions().split(";") : null; + if (names != null) { + for (int i = 0; i < names.length; i++) { + MsExtractJSONPath jsonPath = new MsExtractJSONPath(); + jsonPath.setVariable(names[i]); + if (values != null && values.length > i) { + jsonPath.setExpression(values[i]); + } + jsonPath.setMultipleMatching(jsonPostProcessor.getComputeConcatenation()); + extract.setName(jsonPostProcessor.getName()); + extract.getJson().add(jsonPath); + } + } } }