diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java index b328123763..deac3e8a7f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestElement.java @@ -98,6 +98,8 @@ public abstract class MsTestElement { private String refType; @JSONField(ordinal = 10) private LinkedList hashTree; + @JSONField(ordinal = 11) + private boolean customizeReq; private MsTestElement parent; @@ -188,15 +190,14 @@ public abstract class MsTestElement { csvDataSet.setEnabled(true); csvDataSet.setProperty(TestElement.TEST_CLASS, CSVDataSet.class.getName()); csvDataSet.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); - csvDataSet.setName(item.getName()); - csvDataSet.setProperty("fileEncoding", item.getEncoding()); - csvDataSet.setProperty("variableNames", item.getName()); + csvDataSet.setName(StringUtils.isEmpty(item.getName()) ? "CSVDataSet" : item.getName()); + csvDataSet.setProperty("fileEncoding", StringUtils.isEmpty(item.getEncoding()) ? "UTF-8" : item.getEncoding()); if (CollectionUtils.isNotEmpty(item.getFiles())) { csvDataSet.setProperty("filename", BODY_FILE_DIR + "/" + item.getFiles().get(0).getId() + "_" + item.getFiles().get(0).getName()); } csvDataSet.setIgnoreFirstLine(false); csvDataSet.setProperty("delimiter", item.getDelimiter()); - csvDataSet.setComment(item.getDescription()); + csvDataSet.setComment(StringUtils.isEmpty(item.getDescription()) ? "" : item.getDescription()); tree.add(csvDataSet); }); } @@ -218,7 +219,7 @@ public abstract class MsTestElement { counterConfig.setVarName(item.getName()); counterConfig.setIncrement(item.getIncrement()); counterConfig.setFormat(item.getValue()); - counterConfig.setComment(item.getDescription()); + counterConfig.setComment(StringUtils.isEmpty(item.getDescription()) ? "" : item.getDescription()); tree.add(counterConfig); }); } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index c9e995547c..acbfa04709 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -79,13 +79,13 @@ public class MsIfController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "empty(" + variable + ")"; + variable = "!empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "!empty(" + variable + ")"; + variable = "empty(" + variable + ")"; operator = ""; value = ""; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index e82c9b07bb..3d05319d2b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -123,13 +123,13 @@ public class MsLoopController extends MsTestElement { } if (StringUtils.equals(operator, "is empty")) { - variable = "empty(" + variable + ")"; + variable = "!empty(" + variable + ")"; operator = ""; value = ""; } if (StringUtils.equals(operator, "is not empty")) { - variable = "!empty(" + variable + ")"; + variable = "empty(" + variable + ")"; operator = ""; value = ""; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 50c790534b..0e0031ace9 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -12,6 +12,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.jmeter.config.Arguments; import org.apache.jmeter.config.ConfigTestElement; import org.apache.jmeter.modifiers.UserParameters; import org.apache.jmeter.protocol.tcp.sampler.TCPSampler; @@ -79,6 +80,13 @@ public class MsTCPSampler extends MsTestElement { } config.setConfig(getEnvironmentConfig(useEnvironment)); parseEnvironment(config.getConfig()); + + // 添加环境中的公共变量 + Arguments arguments = this.addArguments(config); + if (arguments != null) { + tree.add(this.addArguments(config)); + } + final HashTree samplerHashTree = new ListedHashTree(); samplerHashTree.add(tcpConfig()); tree.set(tcpSampler(config), samplerHashTree); @@ -94,7 +102,7 @@ public class MsTCPSampler extends MsTestElement { } private void parseEnvironment(EnvironmentConfig config) { - if (config != null && config.getTcpConfig() != null) { + if (!isCustomizeReq() && config != null && config.getTcpConfig() != null) { this.server = config.getTcpConfig().getServer(); this.port = config.getTcpConfig().getPort(); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 7a57cdb36a..fbd9904977 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -516,7 +516,6 @@ public class ApiAutomationService { ParameterConfig config = new ParameterConfig(); config.setConfig(envConfig); HashTree hashTree = request.getTestElement().generateHashTree(config); - // 调用执行方法 createScenarioReport(request.getId(), request.getScenarioId(), request.getScenarioName(), ReportTriggerMode.MANUAL.name(), request.getExecuteType(), request.getProjectId(), SessionUtils.getUserId()); @@ -717,7 +716,9 @@ public class ApiAutomationService { apiScenarios.forEach(item -> { JSONObject object = JSONObject.parseObject(item.getScenarioDefinition()); object.put("environmentId", request.getEnvironmentId()); - item.setScenarioDefinition(JSONObject.toJSONString(object)); + if (object != null) { + item.setScenarioDefinition(JSONObject.toJSONString(object)); + } apiScenarioMapper.updateByPrimaryKeySelective(item); }); } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index 0d16831558..bab86e7b27 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -235,6 +235,7 @@ this.loading = true; this.runData = []; this.request.useEnvironment = this.currentEnvironmentId; + this.request.customizeReq = this.isCustomizeReq; let debugData = { id: this.currentScenario.id, name: this.currentScenario.name, type: "scenario", variables: this.currentScenario.variables, referenced: 'Created', enableCookieShare: this.enableCookieShare, diff --git a/frontend/src/business/components/api/definition/ApiDefinition.vue b/frontend/src/business/components/api/definition/ApiDefinition.vue index b741e64efc..55ecc124b3 100644 --- a/frontend/src/business/components/api/definition/ApiDefinition.vue +++ b/frontend/src/business/components/api/definition/ApiDefinition.vue @@ -406,7 +406,6 @@ }, setNodeTree(data) { this.nodeTree = data; - console.log( this.nodeTree) }, changeSelectDataRangeAll(tableType) { this.$route.params.dataSelectRange = 'all'; diff --git a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue index 021c0aaa71..0b983ea1c8 100644 --- a/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue +++ b/frontend/src/business/components/api/definition/components/case/ApiCaseItem.vue @@ -278,7 +278,9 @@ url = "/api/testcase/update"; } else { tmp.request.path = this.api.path; - tmp.request.method = this.api.method; + if (tmp.request.protocol != "dubbo://" && tmp.request.protocol != "DUBBO") { + tmp.request.method = this.api.method; + } } if (tmp.tags instanceof Array) { tmp.tags = JSON.stringify(tmp.tags); diff --git a/frontend/src/business/components/api/test/components/jar/JarConfig.vue b/frontend/src/business/components/api/test/components/jar/JarConfig.vue index 3380217048..474401a3e4 100644 --- a/frontend/src/business/components/api/test/components/jar/JarConfig.vue +++ b/frontend/src/business/components/api/test/components/jar/JarConfig.vue @@ -72,4 +72,9 @@ diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index 30602936cc..12f9460f3d 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -322,21 +322,23 @@ export function _getBodyUploadFiles(request, bodyUploadFiles, obj) { body = request.body; } if (body) { - body.kvs.forEach(param => { - if (param.files) { - param.files.forEach(item => { - if (item.file) { - if (!item.id) { - let fileId = getUUID().substring(0, 12); - item.name = item.file.name; - item.id = fileId; + if (body.kvs) { + body.kvs.forEach(param => { + if (param.files) { + param.files.forEach(item => { + if (item.file) { + if (!item.id) { + let fileId = getUUID().substring(0, 12); + item.name = item.file.name; + item.id = fileId; + } + obj.bodyUploadIds.push(item.id); + bodyUploadFiles.push(item.file); } - obj.bodyUploadIds.push(item.id); - bodyUploadFiles.push(item.file); - } - }); - } - }); + }); + } + }); + } if (body.binary) { body.binary.forEach(param => { if (param.files) {