refactor(接口测试): 部分对象代码优化

This commit is contained in:
fit2-zhao 2022-01-21 11:19:40 +08:00 committed by fit2-zhao
parent 03b9de082d
commit ec69dba65a
24 changed files with 26 additions and 23 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<MsAssertionRegex> regex;
private List<MsAssertionJsonPath> jsonPath;

View File

@ -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;

View File

@ -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<KeyValue> headers;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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<MsTestElement> hashTree, MsParameter msParameter) {

View File

@ -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<MsExtractRegex> regex;
private List<MsExtractJSONPath> json;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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 必须放最前面以便能够转换正确的类

View File

@ -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;

View File

@ -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;

View File

@ -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 = "";

View File

@ -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;

View File

@ -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;

View File

@ -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 {