From 5673555d2d725599c09a3694a9d1f9d43671b4b0 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 23 Jul 2021 12:36:10 +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=E8=B0=83=E8=AF=95=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=8C=B9=E9=85=8D=E9=97=AE=E9=A2=98=EF=BC=8Clog?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E4=B8=8D=E5=85=A8=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/assertions/MsAssertions.java | 12 +++++++++++ .../definition/request/extract/MsExtract.java | 9 +++++++++ .../api/jmeter/JmeterLoggerAppender.java | 20 +++++++++---------- .../automation/scenario/EditApiScenario.vue | 10 +++++++--- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java index 97510aec1c..1ebf31c486 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/assertions/MsAssertions.java @@ -68,6 +68,9 @@ public class MsAssertions extends MsTestElement { ResponseAssertion assertion = new ResponseAssertion(); assertion.setEnabled(this.isEnable()); assertion.setName(assertionRegex.getDescription()); + if(StringUtils.isEmpty(assertionRegex.getDescription())){ + assertion.setName("AssertionRegex"); + } assertion.setName(StringUtils.isNotEmpty(assertionRegex.getDescription()) ? assertionRegex.getDescription() : this.getName()); assertion.setProperty(TestElement.TEST_CLASS, ResponseAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui")); @@ -94,6 +97,9 @@ public class MsAssertions extends MsTestElement { JSONPathAssertion assertion = new JSONPathAssertion(); assertion.setEnabled(this.isEnable()); assertion.setName(StringUtils.isNotEmpty(assertionJsonPath.getDescription()) ? assertionJsonPath.getDescription() : this.getName()); + if(StringUtils.isEmpty(assertion.getName())){ + assertion.setName("JSONPathAssertion"); + } /* assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "JSONPathAssertion");*/ assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui")); @@ -115,6 +121,9 @@ public class MsAssertions extends MsTestElement { XPath2Assertion assertion = new XPath2Assertion(); assertion.setEnabled(this.isEnable()); assertion.setName(StringUtils.isNotEmpty(assertionXPath2.getExpression()) ? assertionXPath2.getExpression() : this.getName()); + if(StringUtils.isEmpty(assertion.getName())){ + assertion.setName("XPath2Assertion"); + } /*assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "XPath2Assertion");*/ assertion.setProperty(TestElement.TEST_CLASS, XPath2Assertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2AssertionGui")); @@ -138,6 +147,9 @@ public class MsAssertions extends MsTestElement { JSR223Assertion assertion = new JSR223Assertion(); assertion.setEnabled(this.isEnable()); assertion.setName(StringUtils.isNotEmpty(assertionJSR223.getDesc()) ? assertionJSR223.getDesc() : this.getName()); + if(StringUtils.isEmpty(assertion.getName())){ + assertion.setName("JSR223Assertion"); + } /*assertion.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "JSR223Assertion");*/ assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java index e9035b7040..e58d422847 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/extract/MsExtract.java @@ -72,6 +72,9 @@ public class MsExtract extends MsTestElement { RegexExtractor extractor = new RegexExtractor(); extractor.setEnabled(this.isEnable()); extractor.setName(StringUtils.isNotEmpty(extractRegex.getVariable()) ? extractRegex.getVariable() : this.getName()); + if(StringUtils.isEmpty(extractor.getName())){ + extractor.setName("RegexExtractor"); + } /*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " RegexExtractor");*/ extractor.setProperty(TestElement.TEST_CLASS, RegexExtractor.class.getName()); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("RegexExtractorGui")); @@ -91,6 +94,9 @@ public class MsExtract extends MsTestElement { XPath2Extractor extractor = new XPath2Extractor(); extractor.setEnabled(this.isEnable()); extractor.setName(StringUtils.isNotEmpty(extractXPath.getVariable()) ? extractXPath.getVariable() : this.getName()); + if(StringUtils.isEmpty(extractor.getName())){ + extractor.setName("XPath2Extractor"); + } /*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " XPath2Extractor");*/ extractor.setProperty(TestElement.TEST_CLASS, XPath2Extractor.class.getName()); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2ExtractorGui")); @@ -107,6 +113,9 @@ public class MsExtract extends MsTestElement { JSONPostProcessor extractor = new JSONPostProcessor(); extractor.setEnabled(this.isEnable()); extractor.setName(StringUtils.isNotEmpty(extractJSONPath.getVariable()) ? extractJSONPath.getVariable() : this.getName()); + if(StringUtils.isEmpty(extractor.getName())){ + extractor.setName("JSONPostProcessor"); + } /*extractor.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : " JSONExtractor");*/ extractor.setProperty(TestElement.TEST_CLASS, JSONPostProcessor.class.getName()); extractor.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPostProcessorGui")); diff --git a/backend/src/main/java/io/metersphere/api/jmeter/JmeterLoggerAppender.java b/backend/src/main/java/io/metersphere/api/jmeter/JmeterLoggerAppender.java index ce71a27619..21d10592df 100644 --- a/backend/src/main/java/io/metersphere/api/jmeter/JmeterLoggerAppender.java +++ b/backend/src/main/java/io/metersphere/api/jmeter/JmeterLoggerAppender.java @@ -17,17 +17,15 @@ public class JmeterLoggerAppender extends UnsynchronizedAppenderBase(); } - if (event.getLevel().levelStr.equals(LogUtil.INFO)) { - StringBuffer message = new StringBuffer(); - message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(" ") - .append(event.getLevel()).append(" ") - .append(event.getThreadName()).append(" ") - .append(event.getFormattedMessage()).append("\n"); - if (logger.containsKey(event.getTimeStamp())) { - logger.get(event.getTimeStamp()).append(message); - } else { - logger.put(event.getTimeStamp(), message); - } + StringBuffer message = new StringBuffer(); + message.append(DateUtils.getTimeStr(event.getTimeStamp())).append(" ") + .append(event.getLevel()).append(" ") + .append(event.getThreadName()).append(" ") + .append(event.getFormattedMessage()).append("\n"); + if (logger.containsKey(event.getTimeStamp())) { + logger.get(event.getTimeStamp()).append(message); + } else { + logger.put(event.getTimeStamp(), message); } } catch (Exception e) { LogUtil.error(e); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 63577755ad..99f601fdcf 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -886,11 +886,11 @@ export default { } }); }, - copySetRes(hashTree) { + resetResourceId(hashTree) { hashTree.forEach(item => { item.resourceId = getUUID(); if (item.hashTree && item.hashTree.length > 0) { - this.copySetRes(item.hashTree); + this.resetResourceId(item.hashTree); } }) }, @@ -901,7 +901,7 @@ export default { let obj = JSON.parse(JSON.stringify(row)); obj.resourceId = getUUID(); if (obj.hashTree && obj.hashTree.length > 0) { - this.copySetRes(obj.hashTree); + this.resetResourceId(obj.hashTree); } if (obj.name) { obj.name = obj.name + '_copy'; @@ -1133,6 +1133,10 @@ export default { this.sort(); }) } + // 初始化resourceId + if (this.scenarioDefinition) { + this.resetResourceId(this.scenarioDefinition); + } }, setParameter() { this.currentScenario.stepTotal = this.scenarioDefinition.length;