From bc09c4ab19e662d446bb8bd2c53846a77fa844ac Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Fri, 21 Jan 2022 11:19:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E9=83=A8=E5=88=86=E5=AF=B9=E8=B1=A1=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 --- .../io/metersphere/api/dto/definition/request/MsScenario.java | 2 +- .../io/metersphere/api/dto/definition/request/MsTestPlan.java | 2 +- .../metersphere/api/dto/definition/request/MsThreadGroup.java | 2 +- .../api/dto/definition/request/assertions/MsAssertions.java | 2 +- .../api/dto/definition/request/auth/MsAuthManager.java | 2 +- .../dto/definition/request/configurations/MsHeaderManager.java | 2 +- .../api/dto/definition/request/controller/MsIfController.java | 2 +- .../dto/definition/request/controller/MsLoopController.java | 2 +- .../definition/request/controller/MsTransactionController.java | 2 +- .../api/dto/definition/request/dns/MsDNSCacheManager.java | 2 +- .../api/dto/definition/request/extract/MsExtract.java | 2 +- .../dto/definition/request/processors/MsJSR223Processor.java | 2 +- .../request/processors/post/MsJDBCPostProcessor.java | 2 +- .../request/processors/post/MsJSR223PostProcessor.java | 2 +- .../definition/request/processors/pre/MsJDBCPreProcessor.java | 2 +- .../request/processors/pre/MsJSR223PreProcessor.java | 2 +- .../api/dto/definition/request/sampler/MsDebugSampler.java | 2 +- .../api/dto/definition/request/sampler/MsDubboSampler.java | 2 +- .../api/dto/definition/request/sampler/MsHTTPSamplerProxy.java | 2 +- .../api/dto/definition/request/sampler/MsJDBCSampler.java | 2 +- .../api/dto/definition/request/sampler/MsTCPSampler.java | 2 +- .../api/dto/definition/request/timer/MsConstantTimer.java | 2 +- .../api/dto/definition/request/unknown/MsJmeterElement.java | 2 +- .../java/io/metersphere/api/service/ApiAutomationService.java | 3 +++ 24 files changed, 26 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java index d7f5d8b65e..dcd4fe4b24 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsScenario.java @@ -46,7 +46,7 @@ import java.util.stream.Collectors; public class MsScenario extends MsTestElement { private String type = "scenario"; - private String clazzName = "io.metersphere.api.dto.definition.request.MsScenario"; + private String clazzName = MsScenario.class.getCanonicalName(); @JSONField(ordinal = 21) private String referenced; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java index 474cf6222d..b123b5db0d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsTestPlan.java @@ -20,7 +20,7 @@ import java.util.List; @JSONType(typeName = "TestPlan") public class MsTestPlan extends MsTestElement { private String type = "TestPlan"; - private String clazzName = "io.metersphere.api.dto.definition.request.MsTestPlan"; + private String clazzName = MsTestPlan.class.getCanonicalName(); private boolean serializeThreadgroups = false; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java index 0e07925294..b4cdec49f0 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/MsThreadGroup.java @@ -36,7 +36,7 @@ import java.util.Map; @JSONType(typeName = "ThreadGroup") public class MsThreadGroup extends MsTestElement { private String type = "ThreadGroup"; - private String clazzName = "io.metersphere.api.dto.definition.request.MsThreadGroup"; + private String clazzName = MsThreadGroup.class.getCanonicalName(); private boolean enableCookieShare; private Boolean onSampleError; 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 d4351db62c..7507cbae04 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 @@ -22,7 +22,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) @JSONType(typeName = "Assertions") public class MsAssertions extends MsTestElement { - private String clazzName = "io.metersphere.api.dto.definition.request.assertions.MsAssertions"; + private String clazzName = MsAssertions.class.getCanonicalName(); private List regex; private List jsonPath; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java index 446f0b5fa4..5dff92897c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/auth/MsAuthManager.java @@ -23,7 +23,7 @@ import java.util.List; @JSONType(typeName = "AuthManager") public class MsAuthManager extends MsTestElement { private String type = "AuthManager"; - private String clazzName = "io.metersphere.api.dto.definition.request.auth.MsAuthManager"; + private String clazzName = MsAuthManager.class.getCanonicalName(); @JSONField(ordinal = 20) private String username; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java index 2ffb7fbb3d..24a5bc33c8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/configurations/MsHeaderManager.java @@ -24,7 +24,7 @@ import java.util.List; public class MsHeaderManager extends MsTestElement { private String type = "HeaderManager"; - private String clazzName = "io.metersphere.api.dto.definition.request.configurations.MsHeaderManager"; + private String clazzName = MsHeaderManager.class.getCanonicalName(); @JSONField(ordinal = 20) private List headers; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java index ca85be8fa5..2262361cf2 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsIfController.java @@ -22,7 +22,7 @@ import java.util.regex.Pattern; @JSONType(typeName = "IfController") public class MsIfController extends MsTestElement { private String type = "IfController"; - private String clazzName = "io.metersphere.api.dto.definition.request.controller.MsIfController"; + private String clazzName = MsIfController.class.getCanonicalName(); private String id; private String variable; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java index 985edc1a6c..74d5476b5e 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsLoopController.java @@ -33,7 +33,7 @@ import java.util.UUID; @JSONType(typeName = "LoopController") public class MsLoopController extends MsTestElement { private String type = "LoopController"; - private String clazzName = "io.metersphere.api.dto.definition.request.controller.MsLoopController"; + private String clazzName = MsLoopController.class.getCanonicalName(); @JSONField(ordinal = 20) private String loopType; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java index ca3a74f610..97ad377e94 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/controller/MsTransactionController.java @@ -20,7 +20,7 @@ import java.util.List; @JSONType(typeName = "TransactionController") public class MsTransactionController extends MsTestElement { private String type = "TransactionController"; - private String clazzName = "io.metersphere.api.dto.definition.request.controller.MsTransactionController"; + private String clazzName = MsTransactionController.class.getCanonicalName(); private String name; private boolean generateParentSample; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java index fb771e9f96..79027fa5b6 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/dns/MsDNSCacheManager.java @@ -25,7 +25,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) @JSONType(typeName = "DNSCacheManager") public class MsDNSCacheManager extends MsTestElement { - private String clazzName = "io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager"; + private String clazzName = MsDNSCacheManager.class.getCanonicalName(); @Override public void toHashTree(HashTree tree, List hashTree, MsParameter msParameter) { 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 98dd6b6ef5..5c9671ed38 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 @@ -24,7 +24,7 @@ import java.util.StringJoiner; @EqualsAndHashCode(callSuper = true) @JSONType(typeName = "Extract") public class MsExtract extends MsTestElement { - private String clazzName = "io.metersphere.api.dto.definition.request.extract.MsExtract"; + private String clazzName = MsExtract.class.getCanonicalName(); private List regex; private List json; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java index a3b73204de..85b77e827d 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/MsJSR223Processor.java @@ -28,7 +28,7 @@ import java.util.List; @JSONType(typeName = "JSR223Processor") public class MsJSR223Processor extends MsTestElement { private String type = "JSR223Processor"; - private String clazzName = "io.metersphere.api.dto.definition.request.processors.MsJSR223Processor"; + private String clazzName = MsJSR223Processor.class.getCanonicalName(); @JSONField(ordinal = 20) private String script; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java index 87d6c02787..67688d2448 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJDBCPostProcessor.java @@ -51,7 +51,7 @@ import java.util.stream.Collectors; public class MsJDBCPostProcessor extends MsTestElement { // type 必须放最前面,以便能够转换正确的类 private String type = "JDBCPostProcessor"; - private String clazzName = "io.metersphere.api.dto.definition.request.processors.post.MsJDBCPostProcessor"; + private String clazzName = MsJDBCPostProcessor.class.getCanonicalName(); @JSONField(ordinal = 20) private DatabaseConfig dataSource; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java index 6b1e5670fa..d78de89e33 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/post/MsJSR223PostProcessor.java @@ -25,7 +25,7 @@ import java.util.List; @JSONType(typeName = "JSR223PostProcessor") public class MsJSR223PostProcessor extends MsTestElement { private String type = "JSR223PostProcessor"; - private String clazzName = "io.metersphere.api.dto.definition.request.processors.post.MsJSR223PostProcessor"; + private String clazzName = MsJSR223PostProcessor.class.getCanonicalName(); @JSONField(ordinal = 20) private String script; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java index 655440b6a3..1bf812db68 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJDBCPreProcessor.java @@ -51,7 +51,7 @@ import java.util.stream.Collectors; public class MsJDBCPreProcessor extends MsTestElement { // type 必须放最前面,以便能够转换正确的类 private String type = "JDBCPreProcessor"; - private String clazzName = "io.metersphere.api.dto.definition.request.processors.pre.MsJDBCPreProcessor"; + private String clazzName = MsJDBCPreProcessor.class.getCanonicalName(); @JSONField(ordinal = 20) private DatabaseConfig dataSource; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java index 5870b827c5..484e9542f8 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/processors/pre/MsJSR223PreProcessor.java @@ -25,7 +25,7 @@ import java.util.List; @JSONType(typeName = "JSR223PreProcessor") public class MsJSR223PreProcessor extends MsTestElement { private String type = "JSR223PreProcessor"; - private String clazzName = "io.metersphere.api.dto.definition.request.processors.pre.MsJSR223PreProcessor"; + private String clazzName = MsJSR223PreProcessor.class.getCanonicalName(); @JSONField(ordinal = 20) private String script; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java index d4e79844b5..3ab225fb44 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDebugSampler.java @@ -20,7 +20,7 @@ import java.util.List; @EqualsAndHashCode(callSuper = true) @JSONType(typeName = "DebugSampler") public class MsDebugSampler extends MsTestElement { - private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsDebugSampler"; + private String clazzName = MsDebugSampler.class.getCanonicalName(); @JSONField(ordinal = 40) private String type = "DebugSampler"; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java index 9bb8bf2bca..5b255b385b 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsDubboSampler.java @@ -44,7 +44,7 @@ import java.util.stream.Collectors; @EqualsAndHashCode(callSuper = true) @JSONType(typeName = "DubboSampler") public class MsDubboSampler extends MsTestElement { - private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsDubboSampler"; + private String clazzName = MsDubboSampler.class.getCanonicalName(); /** * type 必须放最前面,以便能够转换正确的类 diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 3773f5656c..9016b9ca0c 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -75,7 +75,7 @@ import java.util.stream.Collectors; @JSONType(typeName = "HTTPSamplerProxy") public class MsHTTPSamplerProxy extends MsTestElement { private String type = "HTTPSamplerProxy"; - private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy"; + private String clazzName = MsHTTPSamplerProxy.class.getCanonicalName(); @JSONField(ordinal = 20) private String protocol; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java index 7d7182b9fd..b3fc354d16 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsJDBCSampler.java @@ -52,7 +52,7 @@ import java.util.stream.Collectors; public class MsJDBCSampler extends MsTestElement { // type 必须放最前面,以便能够转换正确的类 private String type = "JDBCSampler"; - private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler"; + private String clazzName = MsJDBCSampler.class.getCanonicalName(); @JSONField(ordinal = 20) private DatabaseConfig dataSource; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java index 46c2774078..8736a3fbf1 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsTCPSampler.java @@ -58,7 +58,7 @@ import java.util.regex.Pattern; public class MsTCPSampler extends MsTestElement { @JSONField(ordinal = 20) private String type = "TCPSampler"; - private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsTCPSampler"; + private String clazzName = MsTCPSampler.class.getCanonicalName(); @JSONField(ordinal = 21) private String classname = ""; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java index 20bb6b90e3..52199a0ad7 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/timer/MsConstantTimer.java @@ -20,7 +20,7 @@ import java.util.List; @JSONType(typeName = "ConstantTimer") public class MsConstantTimer extends MsTestElement { private String type = "ConstantTimer"; - private String clazzName = "io.metersphere.api.dto.definition.request.timer.MsConstantTimer"; + private String clazzName = MsConstantTimer.class.getCanonicalName(); @JSONField(ordinal = 20) private String id; diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java index 1630609536..b375f4947f 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/unknown/MsJmeterElement.java @@ -34,7 +34,7 @@ import java.util.stream.Collectors; @JSONType(typeName = "JmeterElement") public class MsJmeterElement extends MsTestElement { private String type = "JmeterElement"; - private String clazzName = "io.metersphere.api.dto.definition.request.unknown.MsJmeterElement"; + private String clazzName = MsJmeterElement.class.getCanonicalName(); private String elementType; private String jmeterElement; diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index f5e29bc1f6..e9688cdf02 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -709,12 +709,14 @@ public class ApiAutomationService { } else { element = refElement; } + element.put("id", apiTestCase.getId()); isExist = true; this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable()); } } else { ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString("id")); if (definitionWithBLOBs != null) { + element.put("id", definitionWithBLOBs.getId()); this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable()); isExist = true; } @@ -738,6 +740,7 @@ public class ApiAutomationService { element.put("referenced", "REF"); element.put("name", scenarioWithBLOBs.getName()); } + element.put("id", scenarioWithBLOBs.getId()); element.put("environmentEnable", environmentEnable); this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable()); } else {