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;