From fb5ef88a9aac55b70b99fb69bcdcc2c5f4ceaa79 Mon Sep 17 00:00:00 2001
From: wxg0103 <727495428@qq.com>
Date: Fri, 26 Nov 2021 14:43:44 +0800
Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?=
=?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8A=A5=E5=91=8A=E8=84=9A=E6=9C=AC=E5=86=85?=
=?UTF-8?q?=E5=AE=B9=E6=98=BE=E7=A4=BA=E4=BF=AE=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../request/assertions/MsAssertions.java | 4 +-
.../api/service/MsResultService.java | 20 +++++--
.../components/response/AssertionResults.vue | 59 ++++++++++++++++++-
3 files changed, 72 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 bf56db71b5..75d1d67cb9 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
@@ -174,9 +174,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" + "==" + this.getName() + "==" + assertionJSR223.getDesc() + "&&" + assertionJSR223.getScript());
} else {
- assertion.setName("JSR223" + "==" + this.getName() + "==" + "JSR223Assertion" + "==" + assertionJSR223.getScript());
+ assertion.setName("JSR223" + "==" + this.getName() + "==" + "JSR223Assertion" + "&&" + assertionJSR223.getScript());
}
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/service/MsResultService.java b/backend/src/main/java/io/metersphere/api/service/MsResultService.java
index 84c749f5db..9b6fa71db2 100644
--- a/backend/src/main/java/io/metersphere/api/service/MsResultService.java
+++ b/backend/src/main/java/io/metersphere/api/service/MsResultService.java
@@ -252,14 +252,22 @@ public class MsResultService {
ResponseAssertionResult responseAssertionResult = new ResponseAssertionResult();
responseAssertionResult.setName(assertionResult.getName());
if (StringUtils.isNotEmpty(assertionResult.getName()) && assertionResult.getName().indexOf("==") != -1) {
- String[] array = assertionResult.getName().split("==");
- if ("JSR223".equals(array[0])) {
- responseAssertionResult.setName(array[1]);
- responseAssertionResult.setContent(array[2]);
- if (array.length > 3) {
- responseAssertionResult.setScript(array[3]);
+ if (assertionResult.getName().indexOf("JSR223") != -1) {
+ String[] array = assertionResult.getName().split("==", 3);
+ if ("JSR223".equals(array[0])) {
+ responseAssertionResult.setName(array[1]);
+ if (array[2].indexOf("&&") != -1) {
+ String[] content = array[2].split("&&");
+ responseAssertionResult.setContent(content[0]);
+ if (content.length > 1) {
+ responseAssertionResult.setScript(content[1]);
+ }
+ } else {
+ responseAssertionResult.setContent(array[2]);
+ }
}
} else {
+ String[] array = assertionResult.getName().split("==");
responseAssertionResult.setName(array[0]);
StringBuffer content = new StringBuffer();
for (int i = 1; i < array.length; i++) {
diff --git a/frontend/src/business/components/api/definition/components/response/AssertionResults.vue b/frontend/src/business/components/api/definition/components/response/AssertionResults.vue
index 63c1ddfab4..c7b0ad9b24 100644
--- a/frontend/src/business/components/api/definition/components/response/AssertionResults.vue
+++ b/frontend/src/business/components/api/definition/components/response/AssertionResults.vue
@@ -13,25 +13,78 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+