From 82b59953ba0a7a45a4ea82072cc62f3fc5060c9e Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Wed, 16 Mar 2022 17:04:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=89=A7=E8=A1=8C=E6=8E=92=E5=BA=8F=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/definition/request/ElementUtil.java | 28 ++++++++++--------- .../automation/scenario/EditApiScenario.vue | 2 ++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java index 1110807513..5ee0e68797 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/ElementUtil.java @@ -51,7 +51,9 @@ import java.util.*; import java.util.stream.Collectors; public class ElementUtil { - + private static final String PRE = "PRE"; + private static final String POST = "POST"; + private static final String ASSERTIONS = "ASSERTIONS"; private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR; public static Arguments addArguments(ParameterConfig config, String projectId, String name) { @@ -649,26 +651,26 @@ public class ElementUtil { Map> groupMap = new LinkedHashMap<>(); elements.forEach(item -> { if ("Assertions".equals(item.getType())) { - if (groupMap.containsKey("Assertions")) { - groupMap.get("Assertions").add(item); + if (groupMap.containsKey(ASSERTIONS)) { + groupMap.get(ASSERTIONS).add(item); } else { - groupMap.put("Assertions", new LinkedList() {{ + groupMap.put(ASSERTIONS, new LinkedList() {{ this.add(item); }}); } } else if (preOperates.contains(item.getType())) { - if (groupMap.containsKey("PreOperate")) { - groupMap.get("PreOperate").add(item); + if (groupMap.containsKey(PRE)) { + groupMap.get(PRE).add(item); } else { - groupMap.put("PreOperate", new LinkedList() {{ + groupMap.put(PRE, new LinkedList() {{ this.add(item); }}); } } else if (postOperates.contains(item.getType())) { - if (groupMap.containsKey("PostOperate")) { - groupMap.get("PostOperate").add(item); + if (groupMap.containsKey(POST)) { + groupMap.get(POST).add(item); } else { - groupMap.put("PostOperate", new LinkedList() {{ + groupMap.put(POST, new LinkedList() {{ this.add(item); }}); } @@ -676,9 +678,9 @@ public class ElementUtil { elementList.add(item); } }); - elementList.addAll(groupMap.get("PreOperate").stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList())); - elementList.addAll(groupMap.get("PostOperate").stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList())); - elementList.addAll(groupMap.get("Assertions").stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList())); + elementList.addAll(groupMap.get(PRE).stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList())); + elementList.addAll(groupMap.get(POST).stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList())); + elementList.addAll(groupMap.get(ASSERTIONS).stream().sorted(Comparator.comparing(MsTestElement::getIndex)).collect(Collectors.toList())); } return elementList; } diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 2bbf646d66..2d2bf051a5 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -653,6 +653,8 @@ export default { } if (item.hashTree && item.hashTree.length > 0) { this.commandTreeNode(item, item.hashTree); + } else { + item.isLeaf = true; } }) if (node) {