From b7d041a869859f2fcea57c95692abdf93d6d8289 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 22 Dec 2021 18:59:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E6=96=AD=E8=A8=80JSONPath=E4=B8=AD=E5=A6=82=E6=9E=9C=E5=8C=85?= =?UTF-8?q?=E5=90=AB=20=3D=3D=E4=BC=9A=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1009053 --user=王孝刚 【github#8619】 断言JSONPath中如果包含 ==会丢失 https://www.tapd.cn/55049933/s/1085441 --- .../request/assertions/MsAssertions.java | 22 ++++++++++--------- .../scenario/maximize/MaximizeScenario.vue | 2 +- 2 files changed, 13 insertions(+), 11 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 75d1d67cb9..eda66e7914 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 @@ -32,6 +32,8 @@ public class MsAssertions extends MsTestElement { private String type = "Assertions"; private MsAssertionDocument document; + private static final String delimiter = "split=="; + @Override public void toHashTree(HashTree tree, List hashTree, MsParameter msParameter) { ParameterConfig config = (ParameterConfig) msParameter; @@ -97,9 +99,9 @@ public class MsAssertions extends MsTestElement { ResponseAssertion assertion = new ResponseAssertion(); assertion.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(assertionRegex.getDescription())) { - assertion.setName(this.getName() + "==" + assertionRegex.getDescription()); + assertion.setName(this.getName() + delimiter + assertionRegex.getDescription()); } else { - assertion.setName(this.getName() + "==" + "AssertionRegex"); + assertion.setName(this.getName() + delimiter + "AssertionRegex"); } assertion.setProperty(TestElement.TEST_CLASS, ResponseAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AssertionGui")); @@ -126,9 +128,9 @@ public class MsAssertions extends MsTestElement { JSONPathAssertion assertion = new JSONPathAssertion(); assertion.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(assertionJsonPath.getDescription())) { - assertion.setName(this.getName() + "==" + assertionJsonPath.getDescription()); + assertion.setName(this.getName() + delimiter + assertionJsonPath.getDescription()); } else { - assertion.setName(this.getName() + "==" + "JSONPathAssertion"); + assertion.setName(this.getName() + delimiter + "JSONPathAssertion"); } assertion.setProperty(TestElement.TEST_CLASS, JSONPathAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("JSONPathAssertionGui")); @@ -146,9 +148,9 @@ public class MsAssertions extends MsTestElement { XPath2Assertion assertion = new XPath2Assertion(); assertion.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(assertionXPath2.getExpression())) { - assertion.setName(this.getName() + "==" + assertionXPath2.getExpression()); + assertion.setName(this.getName() + delimiter + assertionXPath2.getExpression()); } else { - assertion.setName(this.getName() + "==" + "XPath2Assertion"); + assertion.setName(this.getName() + delimiter + "XPath2Assertion"); } assertion.setProperty(TestElement.TEST_CLASS, XPath2Assertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("XPath2AssertionGui")); @@ -160,9 +162,9 @@ public class MsAssertions extends MsTestElement { private DurationAssertion durationAssertion(MsAssertionDuration assertionDuration) { DurationAssertion assertion = new DurationAssertion(); assertion.setEnabled(this.isEnable()); - assertion.setName("" + "==" + "Response In Time: " + assertionDuration.getValue()); + assertion.setName("" + delimiter + "Response In Time: " + assertionDuration.getValue()); if (StringUtils.isNotEmpty(this.getName())) { - assertion.setName(this.getName() + "==" + "Response In Time: " + assertionDuration.getValue()); + assertion.setName(this.getName() + delimiter + "Response In Time: " + assertionDuration.getValue()); } assertion.setProperty(TestElement.TEST_CLASS, DurationAssertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("DurationAssertionGui")); @@ -174,9 +176,9 @@ public class MsAssertions extends MsTestElement { JSR223Assertion assertion = new JSR223Assertion(); assertion.setEnabled(this.isEnable()); if (StringUtils.isNotEmpty(assertionJSR223.getDesc())) { - assertion.setName("JSR223" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "&&" + assertionJSR223.getScript()); + assertion.setName("JSR223" + delimiter + this.getName() + delimiter + assertionJSR223.getDesc() + "&&" + assertionJSR223.getScript()); } else { - assertion.setName("JSR223" + "==" + this.getName() + "==" + "JSR223Assertion" + "&&" + assertionJSR223.getScript()); + assertion.setName("JSR223" + delimiter + this.getName() + delimiter + "JSR223Assertion" + "&&" + assertionJSR223.getScript()); } assertion.setProperty(TestElement.TEST_CLASS, JSR223Assertion.class.getName()); assertion.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestBeanGUI")); diff --git a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue index 31efc346db..a2e49cb431 100644 --- a/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/maximize/MaximizeScenario.vue @@ -460,7 +460,7 @@ export default { if (arr && arr.length > 0) { arr.forEach(item => { if (item.id === this.currentScenario.id) { - this.$error("不能引用或复制自身!"); + this.$error(this.$t('api_test.scenario.scenario_error')); return; } if (!item.hashTree) {