refactor(接口测试): 部分对象代码优化
This commit is contained in:
parent
8cda61ec9f
commit
bc09c4ab19
|
@ -46,7 +46,7 @@ import java.util.stream.Collectors;
|
||||||
public class MsScenario extends MsTestElement {
|
public class MsScenario extends MsTestElement {
|
||||||
|
|
||||||
private String type = "scenario";
|
private String type = "scenario";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.MsScenario";
|
private String clazzName = MsScenario.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 21)
|
@JSONField(ordinal = 21)
|
||||||
private String referenced;
|
private String referenced;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "TestPlan")
|
@JSONType(typeName = "TestPlan")
|
||||||
public class MsTestPlan extends MsTestElement {
|
public class MsTestPlan extends MsTestElement {
|
||||||
private String type = "TestPlan";
|
private String type = "TestPlan";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.MsTestPlan";
|
private String clazzName = MsTestPlan.class.getCanonicalName();
|
||||||
|
|
||||||
private boolean serializeThreadgroups = false;
|
private boolean serializeThreadgroups = false;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.Map;
|
||||||
@JSONType(typeName = "ThreadGroup")
|
@JSONType(typeName = "ThreadGroup")
|
||||||
public class MsThreadGroup extends MsTestElement {
|
public class MsThreadGroup extends MsTestElement {
|
||||||
private String type = "ThreadGroup";
|
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 enableCookieShare;
|
||||||
private Boolean onSampleError;
|
private Boolean onSampleError;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.List;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = "Assertions")
|
@JSONType(typeName = "Assertions")
|
||||||
public class MsAssertions extends MsTestElement {
|
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<MsAssertionRegex> regex;
|
||||||
private List<MsAssertionJsonPath> jsonPath;
|
private List<MsAssertionJsonPath> jsonPath;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "AuthManager")
|
@JSONType(typeName = "AuthManager")
|
||||||
public class MsAuthManager extends MsTestElement {
|
public class MsAuthManager extends MsTestElement {
|
||||||
private String type = "AuthManager";
|
private String type = "AuthManager";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.auth.MsAuthManager";
|
private String clazzName = MsAuthManager.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private String username;
|
private String username;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||||
public class MsHeaderManager extends MsTestElement {
|
public class MsHeaderManager extends MsTestElement {
|
||||||
|
|
||||||
private String type = "HeaderManager";
|
private String type = "HeaderManager";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.configurations.MsHeaderManager";
|
private String clazzName = MsHeaderManager.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private List<KeyValue> headers;
|
private List<KeyValue> headers;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.regex.Pattern;
|
||||||
@JSONType(typeName = "IfController")
|
@JSONType(typeName = "IfController")
|
||||||
public class MsIfController extends MsTestElement {
|
public class MsIfController extends MsTestElement {
|
||||||
private String type = "IfController";
|
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 id;
|
||||||
private String variable;
|
private String variable;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.UUID;
|
||||||
@JSONType(typeName = "LoopController")
|
@JSONType(typeName = "LoopController")
|
||||||
public class MsLoopController extends MsTestElement {
|
public class MsLoopController extends MsTestElement {
|
||||||
private String type = "LoopController";
|
private String type = "LoopController";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.controller.MsLoopController";
|
private String clazzName = MsLoopController.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private String loopType;
|
private String loopType;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "TransactionController")
|
@JSONType(typeName = "TransactionController")
|
||||||
public class MsTransactionController extends MsTestElement {
|
public class MsTransactionController extends MsTestElement {
|
||||||
private String type = "TransactionController";
|
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 String name;
|
||||||
private boolean generateParentSample;
|
private boolean generateParentSample;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = "DNSCacheManager")
|
@JSONType(typeName = "DNSCacheManager")
|
||||||
public class MsDNSCacheManager extends MsTestElement {
|
public class MsDNSCacheManager extends MsTestElement {
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.dns.MsDNSCacheManager";
|
private String clazzName = MsDNSCacheManager.class.getCanonicalName();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, MsParameter msParameter) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.StringJoiner;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = "Extract")
|
@JSONType(typeName = "Extract")
|
||||||
public class MsExtract extends MsTestElement {
|
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<MsExtractRegex> regex;
|
||||||
private List<MsExtractJSONPath> json;
|
private List<MsExtractJSONPath> json;
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "JSR223Processor")
|
@JSONType(typeName = "JSR223Processor")
|
||||||
public class MsJSR223Processor extends MsTestElement {
|
public class MsJSR223Processor extends MsTestElement {
|
||||||
private String type = "JSR223Processor";
|
private String type = "JSR223Processor";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.processors.MsJSR223Processor";
|
private String clazzName = MsJSR223Processor.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private String script;
|
private String script;
|
||||||
|
|
|
@ -51,7 +51,7 @@ import java.util.stream.Collectors;
|
||||||
public class MsJDBCPostProcessor extends MsTestElement {
|
public class MsJDBCPostProcessor extends MsTestElement {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = "JDBCPostProcessor";
|
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)
|
@JSONField(ordinal = 20)
|
||||||
private DatabaseConfig dataSource;
|
private DatabaseConfig dataSource;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "JSR223PostProcessor")
|
@JSONType(typeName = "JSR223PostProcessor")
|
||||||
public class MsJSR223PostProcessor extends MsTestElement {
|
public class MsJSR223PostProcessor extends MsTestElement {
|
||||||
private String type = "JSR223PostProcessor";
|
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)
|
@JSONField(ordinal = 20)
|
||||||
private String script;
|
private String script;
|
||||||
|
|
|
@ -51,7 +51,7 @@ import java.util.stream.Collectors;
|
||||||
public class MsJDBCPreProcessor extends MsTestElement {
|
public class MsJDBCPreProcessor extends MsTestElement {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = "JDBCPreProcessor";
|
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)
|
@JSONField(ordinal = 20)
|
||||||
private DatabaseConfig dataSource;
|
private DatabaseConfig dataSource;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "JSR223PreProcessor")
|
@JSONType(typeName = "JSR223PreProcessor")
|
||||||
public class MsJSR223PreProcessor extends MsTestElement {
|
public class MsJSR223PreProcessor extends MsTestElement {
|
||||||
private String type = "JSR223PreProcessor";
|
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)
|
@JSONField(ordinal = 20)
|
||||||
private String script;
|
private String script;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = "DebugSampler")
|
@JSONType(typeName = "DebugSampler")
|
||||||
public class MsDebugSampler extends MsTestElement {
|
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)
|
@JSONField(ordinal = 40)
|
||||||
private String type = "DebugSampler";
|
private String type = "DebugSampler";
|
||||||
|
|
|
@ -44,7 +44,7 @@ import java.util.stream.Collectors;
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@JSONType(typeName = "DubboSampler")
|
@JSONType(typeName = "DubboSampler")
|
||||||
public class MsDubboSampler extends MsTestElement {
|
public class MsDubboSampler extends MsTestElement {
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsDubboSampler";
|
private String clazzName = MsDubboSampler.class.getCanonicalName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* type 必须放最前面,以便能够转换正确的类
|
* type 必须放最前面,以便能够转换正确的类
|
||||||
|
|
|
@ -75,7 +75,7 @@ import java.util.stream.Collectors;
|
||||||
@JSONType(typeName = "HTTPSamplerProxy")
|
@JSONType(typeName = "HTTPSamplerProxy")
|
||||||
public class MsHTTPSamplerProxy extends MsTestElement {
|
public class MsHTTPSamplerProxy extends MsTestElement {
|
||||||
private String type = "HTTPSamplerProxy";
|
private String type = "HTTPSamplerProxy";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy";
|
private String clazzName = MsHTTPSamplerProxy.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private String protocol;
|
private String protocol;
|
||||||
|
|
|
@ -52,7 +52,7 @@ import java.util.stream.Collectors;
|
||||||
public class MsJDBCSampler extends MsTestElement {
|
public class MsJDBCSampler extends MsTestElement {
|
||||||
// type 必须放最前面,以便能够转换正确的类
|
// type 必须放最前面,以便能够转换正确的类
|
||||||
private String type = "JDBCSampler";
|
private String type = "JDBCSampler";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsJDBCSampler";
|
private String clazzName = MsJDBCSampler.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private DatabaseConfig dataSource;
|
private DatabaseConfig dataSource;
|
||||||
|
|
|
@ -58,7 +58,7 @@ import java.util.regex.Pattern;
|
||||||
public class MsTCPSampler extends MsTestElement {
|
public class MsTCPSampler extends MsTestElement {
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private String type = "TCPSampler";
|
private String type = "TCPSampler";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.sampler.MsTCPSampler";
|
private String clazzName = MsTCPSampler.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 21)
|
@JSONField(ordinal = 21)
|
||||||
private String classname = "";
|
private String classname = "";
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
@JSONType(typeName = "ConstantTimer")
|
@JSONType(typeName = "ConstantTimer")
|
||||||
public class MsConstantTimer extends MsTestElement {
|
public class MsConstantTimer extends MsTestElement {
|
||||||
private String type = "ConstantTimer";
|
private String type = "ConstantTimer";
|
||||||
private String clazzName = "io.metersphere.api.dto.definition.request.timer.MsConstantTimer";
|
private String clazzName = MsConstantTimer.class.getCanonicalName();
|
||||||
|
|
||||||
@JSONField(ordinal = 20)
|
@JSONField(ordinal = 20)
|
||||||
private String id;
|
private String id;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.util.stream.Collectors;
|
||||||
@JSONType(typeName = "JmeterElement")
|
@JSONType(typeName = "JmeterElement")
|
||||||
public class MsJmeterElement extends MsTestElement {
|
public class MsJmeterElement extends MsTestElement {
|
||||||
private String type = "JmeterElement";
|
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 elementType;
|
||||||
private String jmeterElement;
|
private String jmeterElement;
|
||||||
|
|
|
@ -709,12 +709,14 @@ public class ApiAutomationService {
|
||||||
} else {
|
} else {
|
||||||
element = refElement;
|
element = refElement;
|
||||||
}
|
}
|
||||||
|
element.put("id", apiTestCase.getId());
|
||||||
isExist = true;
|
isExist = true;
|
||||||
this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable());
|
this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString("id"));
|
ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString("id"));
|
||||||
if (definitionWithBLOBs != null) {
|
if (definitionWithBLOBs != null) {
|
||||||
|
element.put("id", definitionWithBLOBs.getId());
|
||||||
this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable());
|
this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable());
|
||||||
isExist = true;
|
isExist = true;
|
||||||
}
|
}
|
||||||
|
@ -738,6 +740,7 @@ public class ApiAutomationService {
|
||||||
element.put("referenced", "REF");
|
element.put("referenced", "REF");
|
||||||
element.put("name", scenarioWithBLOBs.getName());
|
element.put("name", scenarioWithBLOBs.getName());
|
||||||
}
|
}
|
||||||
|
element.put("id", scenarioWithBLOBs.getId());
|
||||||
element.put("environmentEnable", environmentEnable);
|
element.put("environmentEnable", environmentEnable);
|
||||||
this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable());
|
this.setElement(element, scenarioWithBLOBs.getNum(), enable, scenarioWithBLOBs.getVersionName(), scenarioWithBLOBs.getVersionEnable());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue