fix(接口定义):规范jmx导入方法
This commit is contained in:
parent
abc533eac3
commit
22855ba8cb
|
@ -497,6 +497,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
elementNode = new MsJmeterElement();
|
||||
elementNode.setName(((TestPlan) key).getName());
|
||||
((MsJmeterElement) elementNode).setJmeterElement(objToXml(key));
|
||||
((MsJmeterElement) elementNode).setElementType(key.getClass().getSimpleName());
|
||||
}
|
||||
// 线程组
|
||||
else if (key instanceof ThreadGroup) {
|
||||
|
@ -614,6 +615,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
|
|||
TestElement testElement = (TestElement) key;
|
||||
elementNode.setName(testElement.getName());
|
||||
((MsJmeterElement) elementNode).setJmeterElement(objToXml(key));
|
||||
((MsJmeterElement) elementNode).setElementType(key.getClass().getSimpleName());
|
||||
}
|
||||
elementNode.setEnable(((TestElement) key).isEnabled());
|
||||
elementNode.setResourceId(UUID.randomUUID().toString());
|
||||
|
|
|
@ -135,7 +135,7 @@ public class MsScenario extends MsTestElement {
|
|||
private Arguments arguments(ParameterConfig config) {
|
||||
Arguments arguments = new Arguments();
|
||||
arguments.setEnabled(true);
|
||||
arguments.setName(this.getName() + "Variables");
|
||||
arguments.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "Arguments");
|
||||
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
||||
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
||||
if (CollectionUtils.isNotEmpty(this.getVariables())) {
|
||||
|
|
|
@ -168,7 +168,7 @@ public abstract class MsTestElement {
|
|||
&& CollectionUtils.isNotEmpty(config.getConfig().getCommonConfig().getVariables())) {
|
||||
Arguments arguments = new Arguments();
|
||||
arguments.setEnabled(true);
|
||||
arguments.setName(name + "Variables");
|
||||
arguments.setName(StringUtils.isNoneBlank(this.getName()) ? this.getName() : "Arguments");
|
||||
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
|
||||
arguments.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("ArgumentsPanel"));
|
||||
config.getConfig().getCommonConfig().getVariables().stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package io.metersphere.api.dto.definition.request;
|
||||
|
||||
import com.alibaba.excel.util.StringUtils;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
@ -29,7 +30,7 @@ public class MsTestPlan extends MsTestElement {
|
|||
}
|
||||
|
||||
public TestPlan getPlan() {
|
||||
TestPlan testPlan = new TestPlan(this.getName() + "TestPlan");
|
||||
TestPlan testPlan = new TestPlan(StringUtils.isEmpty(this.getName()) ? "TestPlan" : this.getName());
|
||||
testPlan.setProperty(TestElement.TEST_CLASS, TestPlan.class.getName());
|
||||
testPlan.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("TestPlanGui"));
|
||||
testPlan.setEnabled(true);
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
|
|||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.protocol.http.control.AuthManager;
|
||||
import org.apache.jmeter.protocol.http.control.Authorization;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -58,7 +59,7 @@ public class MsAuthManager extends MsTestElement {
|
|||
}
|
||||
AuthManager authManager = new AuthManager();
|
||||
authManager.setEnabled(true);
|
||||
authManager.setName(this.getUsername() + "AuthManager");
|
||||
authManager.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "AuthManager");
|
||||
authManager.setProperty(TestElement.TEST_CLASS, AuthManager.class.getName());
|
||||
authManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("AuthPanel"));
|
||||
Authorization auth = new Authorization();
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.api.dto.scenario.KeyValue;
|
|||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.jmeter.protocol.http.control.Header;
|
||||
import org.apache.jmeter.protocol.http.control.HeaderManager;
|
||||
import org.apache.jmeter.save.SaveService;
|
||||
|
@ -29,7 +30,7 @@ public class MsHeaderManager extends MsTestElement {
|
|||
public void toHashTree(HashTree tree, List<MsTestElement> hashTree, ParameterConfig config) {
|
||||
HeaderManager headerManager = new HeaderManager();
|
||||
headerManager.setEnabled(this.isEnable());
|
||||
headerManager.setName(this.getName() + "Headers");
|
||||
headerManager.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "HeaderManager");
|
||||
headerManager.setProperty(TestElement.TEST_CLASS, HeaderManager.class.getName());
|
||||
headerManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HeaderPanel"));
|
||||
headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
|
|
|
@ -78,7 +78,7 @@ public class MsLoopController extends MsTestElement {
|
|||
private CounterConfig addCounterConfig() {
|
||||
CounterConfig counterConfig = new CounterConfig();
|
||||
counterConfig.setVarName("LoopCounterConfigXXX");
|
||||
counterConfig.setName("LoopCounterConfigXXX");
|
||||
counterConfig.setName("数循结果统计计数器");
|
||||
counterConfig.setEnabled(true);
|
||||
counterConfig.setProperty(TestElement.TEST_CLASS, CounterConfig.class.getName());
|
||||
counterConfig.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("CounterConfigGui"));
|
||||
|
|
|
@ -305,7 +305,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
|
|||
public void setHeader(HashTree tree, List<KeyValue> headers) {
|
||||
HeaderManager headerManager = new HeaderManager();
|
||||
headerManager.setEnabled(true);
|
||||
headerManager.setName(this.getName() + "Headers");
|
||||
headerManager.setName(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "HeaderManager");
|
||||
headerManager.setProperty(TestElement.TEST_CLASS, HeaderManager.class.getName());
|
||||
headerManager.setProperty(TestElement.GUI_CLASS, SaveService.aliasToClass("HeaderPanel"));
|
||||
headers.stream().filter(KeyValue::isValid).filter(KeyValue::isEnable).forEach(keyValue ->
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
private List<KeyValue> variables;
|
||||
@JSONField(ordinal = 26)
|
||||
private String environmentId;
|
||||
// @JSONField(ordinal = 27)
|
||||
// @JSONField(ordinal = 27)
|
||||
// private Object requestResult;
|
||||
@JSONField(ordinal = 28)
|
||||
private String dataSourceId;
|
||||
|
@ -67,7 +67,7 @@ public class MsJDBCSampler extends MsTestElement {
|
|||
}
|
||||
final HashTree samplerHashTree = tree.add(jdbcSampler(config));
|
||||
tree.add(jdbcDataSource());
|
||||
Arguments arguments = arguments(this.getName() + " Variables", this.getVariables());
|
||||
Arguments arguments = arguments(StringUtils.isNotEmpty(this.getName()) ? this.getName() : "Arguments", this.getVariables());
|
||||
if (arguments != null) {
|
||||
tree.add(arguments);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
@JSONType(typeName = "JmeterElement")
|
||||
public class MsJmeterElement extends MsTestElement {
|
||||
private String type = "JmeterElement";
|
||||
|
||||
private String elementType;
|
||||
private String jmeterElement;
|
||||
|
||||
@Override
|
||||
|
@ -34,6 +34,7 @@ public class MsJmeterElement extends MsTestElement {
|
|||
if (inputSource != null) {
|
||||
Object scriptWrapper = SaveService.loadElement(inputSource);
|
||||
HashTree elementTree = tree;
|
||||
this.setElementType(scriptWrapper.getClass().getName());
|
||||
if (config.isOperating()) {
|
||||
elementTree = tree.add(scriptWrapper);
|
||||
} else if (!(scriptWrapper instanceof TestPlan) && !(scriptWrapper instanceof ThreadGroup)) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit b9042074b780205e275c674f64417799110519fd
|
||||
Subproject commit 5e0b365f1080197e84055e80071165787e2e79c5
|
|
@ -6,7 +6,7 @@
|
|||
:draggable="draggable"
|
||||
:color="defColor"
|
||||
:background-color="defBackgroundColor"
|
||||
:title="defTitle">
|
||||
:title="request.elementType">
|
||||
|
||||
</api-base-component>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue