From c2157e48d9fd99b457f309a095a5f3fe08539816 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Thu, 17 Jun 2021 14:56:15 +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=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=8E=A7=E5=88=B6=E5=99=A8=E5=B1=82=E7=BA=A7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/MsTestElement.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) 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 ca39cc1519..4ab7bb8274 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 @@ -77,7 +77,7 @@ import java.util.stream.Collectors; }) @JSONType(seeAlso = {MsHTTPSamplerProxy.class, MsHeaderManager.class, MsJSR223Processor.class, MsJSR223PostProcessor.class, MsJSR223PreProcessor.class, MsTestPlan.class, MsThreadGroup.class, MsAuthManager.class, MsAssertions.class, - MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class,MsTransactionController.class, MsScenario.class, MsLoopController.class, MsJmeterElement.class}, typeKey = "type") + MsExtract.class, MsTCPSampler.class, MsDubboSampler.class, MsJDBCSampler.class, MsConstantTimer.class, MsIfController.class, MsTransactionController.class, MsScenario.class, MsLoopController.class, MsJmeterElement.class}, typeKey = "type") @Data public abstract class MsTestElement { private String type; @@ -257,7 +257,20 @@ public abstract class MsTestElement { if (element.getParent() == null) { return path; } - path = StringUtils.isEmpty(element.getName()) ? element.getType() : element.getName() + DelimiterConstants.STEP_DELIMITER.toString() + path; + if (MsTestElementConstants.LoopController.name().equals(element.getType())) { + MsLoopController loopController = (MsLoopController) element; + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) { + path = "While 循环" + DelimiterConstants.STEP_DELIMITER.toString() + "While 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}"; + } + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) { + path = "ForEach 循环" + DelimiterConstants.STEP_DELIMITER.toString() + " ForEach 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}"; + } + if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) { + path = "次数循环" + DelimiterConstants.STEP_DELIMITER.toString() + "次数循环-" + "${MS_LOOP_CONTROLLER_CONFIG}"; + } + } else { + path = StringUtils.isEmpty(element.getName()) ? element.getType() : element.getName() + DelimiterConstants.STEP_DELIMITER.toString() + path; + } return getFullPath(element.getParent(), path); } @@ -273,24 +286,13 @@ public abstract class MsTestElement { protected String getParentName(MsTestElement parent) { if (parent != null) { - if (MsTestElementConstants.LoopController.name().equals(parent.getType())) { - MsLoopController loopController = (MsLoopController) parent; - if (StringUtils.equals(loopController.getLoopType(), LoopConstants.WHILE.name()) && loopController.getWhileController() != null) { - return "While 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}"; - } - if (StringUtils.equals(loopController.getLoopType(), LoopConstants.FOREACH.name()) && loopController.getForEachController() != null) { - return "ForEach 循环-" + "${MS_LOOP_CONTROLLER_CONFIG}"; - } - if (StringUtils.equals(loopController.getLoopType(), LoopConstants.LOOP_COUNT.name()) && loopController.getCountController() != null) { - return "次数循环-" + "${MS_LOOP_CONTROLLER_CONFIG}"; - } - }else if(MsTestElementConstants.TransactionController.name().equals(parent.getType())){ - MsTransactionController transactionController = (MsTransactionController)parent; - if(StringUtils.isNotEmpty(transactionController.getName())){ + if (MsTestElementConstants.TransactionController.name().equals(parent.getType())) { + MsTransactionController transactionController = (MsTransactionController) parent; + if (StringUtils.isNotEmpty(transactionController.getName())) { return transactionController.getName(); - }else if(StringUtils.isNotEmpty(transactionController.getLabelName())){ + } else if (StringUtils.isNotEmpty(transactionController.getLabelName())) { return transactionController.getLabelName(); - }else { + } else { return "TransactionController"; } }