From 68dcdc741446436e6360b97e7ca857cfabc48f91 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 10 Jan 2024 19:17:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=8E=86=E5=8F=B2=E9=81=97=E7=95=99=E6=96=AD?= =?UTF-8?q?=E8=A8=80=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/ElementUtil.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 8d4b315e3e..9ed70f74d7 100644 --- a/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/api-test/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -413,6 +413,31 @@ public class ElementUtil { } } + + public static LinkedList mergeOrgAssertion(LinkedList orgAssertions) { + if (CollectionUtils.isNotEmpty(orgAssertions) && orgAssertions.size() > 1) { + //根据不同的类型,把所有的数据都合并到第一个上 + MsAssertions target = (MsAssertions) orgAssertions.get(0); + for (int i = 1; i < orgAssertions.size(); i++) { + MsAssertions target1 = (MsAssertions) orgAssertions.get(i); + mergeArrayAssertions(target.getJsonPath(), target1.getJsonPath()); + mergeArrayAssertions(target.getXpath2(), target1.getXpath2()); + mergeArrayAssertions(target.getJsr223(), target1.getJsr223()); + mergeArrayAssertions(target.getRegex(), target1.getRegex()); + } + LinkedList msTestElements = new LinkedList<>(); + msTestElements.add(target); + return msTestElements; + } + return orgAssertions; + } + + public static void mergeArrayAssertions(List org, List org1) { + if (CollectionUtils.isNotEmpty(org1)) { + org.addAll(org1); + } + } + public static void mergeHashTree(MsTestElement element, LinkedList targetHashTree) { try { Map> source = groupCase(element.getHashTree()); @@ -420,6 +445,8 @@ public class ElementUtil { List step = new LinkedList<>(); List pre = ElementUtil.mergeCaseHashTree(source.get(PRE), target.get(PRE)); List post = ElementUtil.mergeCaseHashTree(source.get(POST), target.get(POST)); + source.put(ASSERTIONS, mergeOrgAssertion(source.get(ASSERTIONS))); + target.put(ASSERTIONS, mergeOrgAssertion(target.get(ASSERTIONS))); List rules = MsHashTreeService.mergeCaseAssertions(source.get(ASSERTIONS), target.get(ASSERTIONS)); if (CollectionUtils.isNotEmpty(pre)) { step.addAll(pre);